So I have a vector<string> tokens that is storing several strings. When I try to print out one of those strings regularly, it gives me a segmentation fault. When I loop through all of the strings and print them with a for loop, it doesn't
This works: for(int i = 0; i < tokens.size(); i++) std::cout << tokens[i] << std::endl;
This gives segmentation fault: std::cout << tokens[0] << std::endl;
I've done research and understand that segmentation faults usually have to do with pointers, but I don't see how the second method of outputting from the tokens vector would have anything to do with that, except for how the string itself is a pointer of char's.
Aucun commentaire:
Enregistrer un commentaire