Hi
I am new to C++ and I would be grateful for some help with the following:
#pragma argsused
int main(int argc, char **argv)
{
AnsiString Line;
int Index;
Line = ReadStringPr("Enter your text. It must not finish with a space character." );
Index = 1;
while (Index <= Length(Line))
if (Line[Index] != ' ');
{
WriteChar(Line[Index]);
Index = Index + 1;
}
else
WriteStringCr(' ');
while (Line[Index] == ' ');
Index = Index + 1;
getchar(); // to keep the display on until you press Enter key
return 0;
}
Using Builder I get a misplaced else statement but I cannot seem to locate the source of the problem. I am trying to remove multiple character spaces entered by the user and output their entered text with only 1 character space between words.
Many thanks!!