Sorry guys, I have to ask this again. I found another thread discussion on this stuff but the poster's example is way too messy, I can't understand their talk at all.
I want to read each character from a string and push those characters one-by-one into a vector. So far, I can do that all. Except, when a conditional statement gets executed before a push the rest of the values change.
For example, if it reads a string "ABC,DEF" it will return on the console screen, "A B C ." but it will return "A B C , D E F" if there is no conditional statement.
std::string temporarydata; std::vector<char> datarow;
std::ifstream inputdata (filename.c_str());
if(inputdata.is_open())
{
while(getline(inputdata,temporarydata))
{
for(int it2=0; it2<temporarydata.length(); it2++)
{
if (temporarydata[it2] != ',')
{
datarow.push_back(temporarydata[it2]);
std::cout << "Temp " << it2 << " is " << temporarydata[it2] << "\n";
std::cout << "Data Rows " << it2 << " is " << datarow[it2] << "\n";
}
}
}
}
What should I do?
Aucun commentaire:
Enregistrer un commentaire