1. ## finding a space

hi, i'm a little confused. i'm trying to find a space in a string, but i can't.

this works fine.
Code:
```for(j = 0; j < 5; j++){
cout<<row[i][j];

if(row[i][j] == 'A'){
cout<<"found A";
break;
}
}```
but if i use space ( ' ' ) instead of 'A', if block is never evaluated as true.

any thoughts?

2. Is there a space in the string?

3. ok guys,

i guess i should've given you more info. i have an input file, and the contents are:
Code:
```TRGSJ
XDOKI
M VLN
WPAB
UIHAB```
space is between M and V!!!!

in my code i read the input:
Code:
```for(i = 0; i < 6; i++)
cin>>row[i];```
row is declared as: string row[i];

when i search the row[i][j], where j is the character in the string, i can't find the space, but any other letter is ok (as i posted earlier).

any suggestions?

4. The code in your initial post will only parse the first line (or whichever value i currently has). You will need another loop for "i" to parse all lines.

5. ya i know, but that's not the problem....i have the outter loop.

ok the bottom line is:

row[i][j] == ' ' will never evaluate to true, even if the character at the position i,j is space (' '). row[i][j] == 'A' however will evaluate to true if the character is A. i know all my other code is correct. i tried: '' and ' ' and "" and " "

6. row[i][j] == ' ' is the correct way to evalue if there is a space there. There is an error in your code somewhere. Post both the inner and outer loops, and maybe someone here could spot the error for you.

7. > cin>>row[i];
cin does not read spaces (it's like scanf("%s") from C)

Use cin.getline() if you want to read a whole line, spaces included

8. >> cin>>row[i];
if you read the input that way, you'll get M and VLN in two different strings, won't you?
You might wanna use getline() so that you'll read by line/row instead of by word
 Salem beat me to the punch [/edit]

9. I can't see all of your code, but I believe your problem is because you are reading in the file one string at a time. The problem is, C++ reads in a string until it hits a whitespace character then stops so in your example above, row[0]="TRGSJ", row[1]="XDOKI", row[2]="M" and row[4]="VLN" etc.

 alpha and salem beat me to the punch [/edit]

10. haha, ya, i just figured that out about cin. thanks a lot