You can't use the standard relational/inequality operators with arrays/C-strings. You either need to loop through element-by-element (works for all arrays), or use the
strcmp() function (works for null-terminated character arrays i.e. C-strings). The latter option is probably what you want here:
CODE
char option[128]={0};
cout << "[Stuff]\n";
while (strcmp(option, "done") ) {
cout << "stuff: ";
cin.getline(option, 128);
}
cout << "Done.\n";
The strcmp() function is a little weird from the usual true/false perspective, since it returns 0 if the strings are equal (hence the lack of the ! in the while control statement). Note that I've also initialized the array
option to zeros, just on the off-chance that the random data in memory at that location starts out with the string "done" (unlikely, but why take a chance?).
Hope that helps,
-jjh
*edit - p.s. or use nirvanarupali's solution above. The std::string is a great little container, and that's probably a cleaner solution, but it's not clear from your code whether you're restricted to using C-style strings for this code.
This post has been edited by jjhaag: 10 Dec, 2007 - 07:08 PM