title: C++ char array characteristic: why does a string stop before the end of the array?
body: <p>I am writing a program in C++. One part of it is this:</p>
  
  <pre><code>std::wcout &lt;&lt; "\nEnter path to seed file: ";
  char Seed_File_Path[255];//Array for the user to enter a file path
  std::cin &gt;&gt; Seed_File_Path;
  
  FILE *seed_file_ifp;                        //Creates pointer to FCB for the seed file.
  seed_file_ifp = fopen(Seed_File_Path, "r"); //opens the file input stream with read permissions.
  
  while (seed_file_ifp == NULL) {//Checks that file was found.
      std::wcout &lt;&lt; "\nFile not found. Enter a valid path and make sure file exists.\n\n";
      std::wcout &lt;&lt; "\nEnter path to seed file: ";
      std::cin &gt;&gt; Seed_File_Path;
      seed_file_ifp = fopen(Seed_File_Path, "r");
  }//Ends if ifp successful
  </code></pre>
  
  <p>I can enter a path less than the size of the array, and the program works as expected. My question is, why does <code>fopen</code> read my path correctly? I would expect it to read in every character in the array, but it reads only what I enter and not past that.</p>
  
  <p>Another characteristic I noticed was that I can enter a large sequence of characters that aren't a valid path (for example, rrrrrr...), then, after the program lets me input a path again, I can enter a smaller sequence of characters that does lead to a valid path (for example, <code>"C:\file.txt"</code>) and <code>fopen</code> is able to use the valid path "correctly". However, I would expect it to use as a string all the characters in the array, which include the valid path plus other, previously entered stuff.</p>
  
  <p>I would like to know the characteristic(s) of an array that cause it to work "correctly," and whether that's a good thing or bad.</p>