title: C++ int to string, concatenate strings
body: <p>I'm new to C++ and working on a simple project. Basically where I'm encountering a problem is creating a file with a number (int) in the file name. As I see it,I have to first convert the int to a string (or char array) and then concatenate this new string with the rest of the file name.</p>
  
  <p>Here is my code so far that fails to compile:</p>
  
  <pre><code>int n; //int to include in filename
  char buffer [33];
  itoa(n, buffer, 10);
  string nStr = string(buffer);
  
  ofstream resultsFile;
  resultsFile.open(string("File - ") + nStr + string(".txt"));
  </code></pre>
  
  <p>This gives a couple compilation errors (compiling in Linux): </p>
  
  <ol>
  <li>itoa not declared in this scope </li>
  <li>no matching function for call to ‘std::basic_ofstream char, std::char_traits char ::open(std::basic_string char, std::char_traits char , std::allocator char )’</li>
  </ol>
  
  <p>I've tried the advice here: <a href="https://stackoverflow.com/questions/5172107/c-string-and-int-concatenation">c string and int concatenation</a>
  and here: <a href="https://stackoverflow.com/questions/5590381/easiest-way-to-convert-int-to-string-in-c">Easiest way to convert int to string in C++</a> with no luck.</p>
  
  <p>If I using the to_string method, I end up with the error "to_string not a member of std". </p>