#include <iostream>
#include <string>
usingnamespace std;
int main()
{
bool blnChar = false;
string text = "safdsA var ifl ; -.67Ç 68.9\"hello \"\" mother!!!\" \'d\' afdsafd , if do";
for (int CharacterIndex = 0; CharacterIndex < (int) text.size(); CharacterIndex++) {
//Getting Char:
if (text[CharacterIndex] == '\'' && blnChar == false) {
cout << "char found at " << CharacterIndex << endl;
blnChar = true;
//Tok.Name += text[CharacterIndex];
//Tok.Type = Token::Char;
}
}
return 0;
}
$ g++ foo.cpp
$ ./a.out
char found at 51
> the 'cout' isn't printed, because i belive "text[CharacterIndex]=='\''" is wrong :(
> but i don't understand why.. can anyone correct me?
So if you're not seeing the printout, you need to post your real code.
that is interesting. locale issue?
what does this print?
int wtf = '\'';
cout << wtf << endl;
all your code sets it to type = Char or the last block does nothing, so it is whatever at that stage. set it to what it needs to be in each block -- you can optimize removal of excess assignments later with a careful trace.
from these text: string text= "safdsA var ifl ; -.67Ç 68.9\"hello \"\" mother!!!\" \'d\' afdsafd , if do";
i need get the: " 'd' " token or: string text= "safdsA var ifl ; -.67Ç 68.9\"hello \"\" mother!!!\" \'\t\' afdsafd , if do";
get the " '\t' "... i update the code:
now my problem was resolved ;)
like everyone see, i just change the ' text[CharacterIndex]=='\'' ' to "int(text[CharacterIndex])==39".
the special characters is best compared converted to a ASCII number(int(CharLetter)))
thank you so much for all