i have file like this
"a",205
"b",214
"c",223
""",13
and i need to parse it
i read line by line to str and i have to convert second character from string to integer, but when it comes to quote <“> character it throws an exception string subscript out of range.
std::string STRING;
std::ifstream infile;
std::vector < std::string > tokens;
infile.open (Filename);
unsigned int x;
while(! infile.eof())
{
std::getline(infile,STRING);
tokens = Utility::splitString(STRING,',');//array of tokens
x = (unsigned int)tokens[0][1];//convert first tokens,second character to uint
}
I think it is something with escape sequence.
tokens[0][1]gets the second character of the first string, which is out of range.The type cast is not the way to convert. use atoi().