Heya everyone,
I'm having a problem with some code that I basically used in quite the same fashion before in a different kind of program, but this time it's not working the way I want it to. Below is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
char fileContent[MAX_NUMBER_OF_PLATFORMPIECES * 21] = {0}; //Variable to hold the file's contents.
string input;
//Some code stuff//
while(((int)fileContent[c] != 44) || ((int)fileContent[c] != 59)) { //Append each next digit to the 'input' variable until a comma or semicolon is encountered.
stringstream ss; //Create a stringstream thing.
string sToAppend; //Create a string to use to append later on.
ss << fileContent[c]; //Put fileContent[c]'s value into the stringstream thing.
ss >> sToAppend; //Put the stringstream thing's value into sToAppend.
input.append(sToAppend);//Append sToAppend to the 'input' variable.
//'input' now holds the old value + the new value.
c++;
}
//Some more code stuff//
|
My problem with this code is that it doesn't properly exit the while loop once it encounters a comma (decimal 44 in ascii) or a semicolon (decimal 59 in ascii). Image that
fileContent = '500,500,0,0,0;'
, here after the second zero the while loop should exit because it encounters a comma, right? It doesn't.
Just something extra to note in case someone would otherwise suggest this: I've tried removing the
(int)
before each
fileContent[c]
but that has no effect whatsoever as far as I can tell, no positive nor negative effect.
Like I said at the beginning: I've used similar code before and there it did recognize the correct symbols.
Does anyone have any idea? If someone wants to entire code, I can post it if needed, but it uses the Allegro Game Library and some custom datafiles and headers which you don't have obviously, so testing it would be a bit harder to do.
Any and all replies are appreciated.