This code is supposed to find a space in a character array and put the seperated string at the space into seperate strings, but doesn't quite work right... It will find any other letter except a space.
If I substitute space = ' '; with space = 'h';, it works fine and splits the string at the first h it sees. Anyone know whats wrong?Code:void Input(char Input[])
{
int x;
int iArg;
string sArg;
string sArg2;
sArg = "";
sArg2 = "";
char space;
space = ' ';
iArg = 0;
for(x = 0;x < strlen(Input);x++)
{
if(iArg == 0)
{
if(Input[x] == space)
{
iArg = 1;
}
else
{
sArg = sArg + Input[x];
}
}
if(iArg == 1)
{
sArg2 = sArg2 + Input[x];
}
}
cout << sArg << endl;