title: String overflow in C++
body: <p>I'm converting large graph files using a simple C++ program. Basically I mainly want to switch the delimiters used in the file. These graph files contain extremely long lines. My converting works fine for small files, but I lose edges in the output file for the large files. So I checked what the part of my code that reads actually returns and it seems the error is already in there. Using the following, I do not receive the full lines from the graph in <code>curLineMetis</code> or <code>ssMetis</code> (My guess is that there's an overflow somewhere and I lose the last part of the line thats too big for the allocated memory)</p>
  
  <pre><code>using namespace std;
  void exampleFunc(const char* inputfileMetis) {
      ifstream metisFile;
      metisFile.open(inputfileMetis, ios::in);
      if(!metisFile.is_open()) {
          cout &lt;&lt; "Could not open input file";
          return;
      }
      long nMet = 0;
      long mMet = 0;
      string curLineMetis;
      // skip first line
      getline(metisFile, curLineMetis);
      while(getline(metisFile, curLineMetis)) {
          nMet++;
          long targetMetis;
          stringstream ssMetis(curLineMetis);
          while(ssMetis &gt;&gt; targetMetis) {
              mMet++;
          }
     }
  }
  </code></pre>
  
  <p>I checked on google and it said std::string managed its own memory and would not overflow? I also tried it without the stringstream, just using an iterator over chars from the string before and the same happened. I'm using c++11 if that makes a difference. (the error expresses itself e.g. in <code>mMet</code> being different from the number of edges stated in the graph file itself, while the number of vertices <code>nMet</code> is the same, and the number of edges is also correct for smaller graphs)</p>