-
problems with spaces...
At the moment i am making a game that requires reading from file and then outputting that. At the moment I cannot output anything after the first space in a line. For example:
char data[50];
fin>>data;
cout<<data;
Here is the file:
This is the data
here is what the program displays:
this
what can i do to fix this?
-
-
Um... Thanx, but could you please tell me what to put IN the fin.getlin()? Becuase i looked it up and i couldnt make heads or tails of it.
-
Sorry I was not more clear. Here is the prototype for the function:
istream& getline( char* pch, int nCount, char delim = '\n' );
So, you might say something like this...
fin.getline( data, 999, '\n' );
This says, store the information from file in the field "data" , second parameter is how many characters to read in, and the last parameter is the delimiter which defaults to newline or can be used if you want to stop when a certain character is reached.