Problems when reading from a FILE and use strtok function
<p>I have writen a code in C++ that must read information from a txt file and when it finds a "|" character it must jump to a new line. Its something quite easy but Im having problems when executing and Ive been trying to find the problem for hours and I havent suceed.  :( I attached the code. </p>

<p>Thaaaanks in advance for your help.</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;fstream&gt;
#include&lt;string&gt;
#include &lt;stdio.h&gt;

using namespace std;

int main ()
{
   string ruta_base( "C:\\a\\" );
   char * pch;

   ifstream myReadFile;
   const string rutaFichero=ruta_base.append("text.txt");
   myReadFile.open(rutaFichero.c_str());

   char* temp;
   if (myReadFile.is_open()) {
      while (!myReadFile.eof()) {
         myReadFile.read(temp,1);

         pch = strtok(temp,"|");
         while (pch != NULL)
         {
            printf ("%s\n",pch);
            pch = strtok (NULL, "|");
         }
      }
   }
   myReadFile.close();

   system("pause");
   return 0;
}
</code></pre>
