wsoxfan1214
Banned
Might be an issue that she has a mac.
That's a rant for a different, day though.
Is there any difference there?
That's a rant for a different, day though.
Is there any difference there?
Might be an issue that she has a mac.
That's a rant for a different, day though.
Is there any difference there?
Aye. As you can tell, I'm new at this.
I'll see if I can get her to install WINE.
Use vim plus g++?
As you can tell, I'm new at this.
I'll see if I can get her to install WINE.
workmac:~ crudediatribe$ g++ foo.cpp
workmac:~ crudediatribe$ ./a.out
--------------------------------------------------------------------------------
| |
| |
| |
| |
| |
| |
| |
| |
| |
--------------------------------------------------------------------------------
^C
workmac:~ crudediatribe$
Use vim plus g++?
This would likely also require packaging custom DLLs in a Windows environment.
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
using namespace std;
int stripWhite(char *str);
int main()
{
char str[100];
cout << "Enter a sentence and I will delete all spaces in it" << endl;
cin.getline(str,100);
int count = stripWhite(str);
cout << count << " white spaces were removed" << endl;
cout << "The string without spaces in it is: " << str << endl;
return 0;
}
int stripWhite(char *str)
{
int i = 0;
int j = 0;
while(str[i] != '\0')
{
if(str[i] == ' ')
j++;
str[i] = '.' ;
i++;
}
return j;
}
What did you intend this
Code:str[i] = '.' ;
to do? Because it is going to replace every character with '.'
Err yes I'm, I don't know what to put in between the ' ' to close the space because my compiler wont simply accept ''
Think of an array the way Haly posted:Err yes I'm, I don't know what to put in between the ' ' to close the space because my compiler wont simply accept ''
If the sentence looked like:
[q][c][k][ ][r][o][w][n]
Err yes I'm, I don't know what to put in between the ' ' to close the space because my compiler wont simply accept ''
while(str != '\0')
{
if(str == ' ')
j++;
str = str[i+1] ;
i++;
}
str[i-1]='\0';
Not sure but wouldn't str = str[i+1] work? And replace null with the last character.
No, you need to think about the next time around the loop. It's possible to do this, but +1 is too rigid. The number of steps over you have to take depends on the number of characters removed.
You're not alone. Almost everyone's a terrible programmer. That's why we write tests.Yes your right. I was always a terrible programmer used alot of trial and error.
Pointer arithmetic makes my head hurtWee.
Pointer arithmetic makes my head hurt![]()
Are there any specific resources (books or online teaching programs) you guys would recommend for learning C++? It is pretty essential to my degree but I won't get to cover it in my course since I've already progressed past that year and the Uni just recently updated their syllabus which only applies to new students.
Accelerated C++. Ignore all other answers as they are inferior.
Yes and yes. It is even, perhaps, more important that you learn from that book as it avoids treating C++ as an extension of C which is a trap a lot of people familiar with C fall into (and become frustrated by). Accelerated C++ is the canonical introduction to the current best practices of C++, and they're a long way off the language's roots.
I think I broke C.
For some reason, if I uncomment either one of four unused variables at the beginning of my main method, my programs dies. I can rename them, I can change their values, but removing them causes chaos.
THIS MAKES NO SENSE
I was just going to send my lecturer a message but it won't hurt to know why it's happening.
I'll send the code via PM. Can't post it here since it's a University assignment.
Our University has a very strict plagiarism policy. Don't want to risk it!Lots of people post their university assignments here.
PM it to me too. Not that I will be able to help, but because I'm curious.
void Populate(string, vector<string>);
int _tmain(int argc, _TCHAR* argv[])
{
//population step
vector<string> Noun;
Populate("Noun.txt", Noun);
//stuff
}
void Populate(string Filename, vector<string> &Vector){
ifstream inFile;
string BufferString;
inFile.open(Filename);
if(!inFile.is_open()){
cout << "Error: " << Filename << " was not found" << endl;
}
while(inFile.good()){
inFile >> BufferString;
Vector.push_back(BufferString);
}
}
Hm, I can't figure out why this code isn't working/compiling:
Code:void Populate(string, vector<string>); int _tmain(int argc, _TCHAR* argv[]) { //population step vector<string> Noun; Populate("Noun.txt", Noun); //stuff } void Populate(string Filename, vector<string> &Vector){ ifstream inFile; string BufferString; inFile.open(Filename); if(!inFile.is_open()){ cout << "Error: " << Filename << " was not found" << endl; } while(inFile.good()){ inFile >> BufferString; Vector.push_back(BufferString); } }
Visual Studio says that "more then one instance of the overloaded function Populate matches the argument list".
Any ideas?
Struct Foo
{
string s;
int i;
double d;
Foo (string a, int b, double c)
{
s = a;
i = b;
d = c;
}
}
Class Bar
{
public:
Foo array[5];
}
int main ()
{
Bar object;
object.array = { Foo("One", 1, 1.0),
Foo("Two", 2, 2.0)
Foo("Three", 3, 3.0)
Foo("Four", 4, 4.0)
Foo("Five", 5, 5.0);
}
Got a question here that I'm stuck on. I have to create an array of structures within a class and then initialize them. As I understand it you cannot initialize something within a class definition outside of a structure. But I'm having problems with the syntax. Here's what I've got:
Code:Struct Foo { string s; int i; double d; } Class Bar { public: Foo array[5]; } int main () { Bar object; object.array = { { "One", 1, 1.0} , { "Two", 2, 2.0 } ....; }
Is this correct?
Try that. Also change string to const char * if that does t work
How would one port a code in C++ from Microsoft Visual Studio 2010 to Apple XCode 4?
How would one port a code in C++ from Microsoft Visual Studio 2010 to Apple XCode 4?
How would one port a code in C++ from Microsoft Visual Studio 2010 to Apple XCode 4?
Oh yeah, sometimes, it's better to recode from scratch. So really consider that option. If it's less than 10K lines, I don't see why you wouldn't do it.