I am trying to break from an infinite for loop, if the user has entered a blank line, but I want to continue if the user has entered a word.
here is code to show.
#include <iostream>
using namespace std;
int main( void )
{
char szMessage[32];
for(;;)
{
cout << "Enter a string: ";
if(cin.get(szMessage, 32));
{
cin.ignore(INT_MAX, '\n');
break;
}
else if(strcmp(szMessage , " "))
{
break;
}
}
system("pause");
return 0;
}
Also, why is there an error on the else if saying, error: expected a statement.
Thanks, for the help