I've made a simple program. I'm reading a text file in the same folder as the program. The file only has one line: " v 1.0 2.0 3.0".
Problem:
When I initialize a stringstream instance ss with a string line, and I use the erase() function to try to remove the character 'v' from the string, it is not working. The MSVC consoles shows the same line of string:
If I remove the .erase(0,1) function, the output is the same.
How could this happen? It should remove the character v. I learn this through the OpenGL's obj loader tutorial, and they can remove it.
Code
#include <sstream>
#include <fstream>
#include <iostream>
int main()
{
std::ifstream filestream("textfile.txt", std::ios::in);
std::string line = "";
while (!filestream.eof())
{
std::getline(filestream, line);
std::cout <<"getline std::string "<< line.c_str()<<std::endl;
std::stringstream ss(line.erase(0,1));
std::cout << "stringstream: " << ss.str() << std::endl;
}
}
