title: Segmentation fault when calling fread() c++
body: <p>I dont understand the mistake I am making.
   I tryed alot but I am unable to read my FILE.
   Basically I write an structure into a file named 0.txt / 1.txt / 2.txt ... based of account amound.
  I realy seached hours to fix my problem but I dont understand how I can fix and why I get the ERROR.
   Also I have no problem in complining my code (with dev c++) but when I press on Load Accounts Button I get the ERROR "<strong>Segmentation Faul</strong>t" (using windows 7).
  I noticed that the <strong>problem is at fread()</strong> line in function ladeAccounts().
  The name of my Structure is "iAccount". 
  The variable infoma is as iAccount typed and the "number of accounts existing" typed as int anzahl in newAccount() decides the path.</p>
  
  <p>iAccount looks like this:</p>
  
  <pre><code> struct iAccount
      {
          string ID;
          string password;
          int level;
      };
  </code></pre>
  
  <p>This is how I write my STRUCT into the FILE:</p>
  
  <pre><code>void Account::newAccount(int anzahl, string username, string pw, int lvl)
      {
          iAccount neu;
          neu.ID = username;
          neu.password = pw;
          neu.level = lvl; 
          ss.str("");
          ss&lt;&lt;anzahl;
          s = ss.str();
          s = "Accounts/"+s+".txt";        
          f1 = fopen(s.c_str(), "w");
          fseek(f1, 0, SEEK_SET);
          fwrite(&amp;infoma, sizeof(iAccount), 1, f1);        
          fclose(f1);             
  
      }
  </code></pre>
  
  <p>This is how I read the File (ERROR APPEARS when I call fread()</p>
  
  <pre><code>void Account::ladeAccount(int nummer)
      {
          stringstream sa;
          iAccount account_geladen;
          sa.str("");
          sa&lt;&lt;nummer;        
          s = sa.str();  
          s = "Accounts/"+s+".txt";     
          f2 = fopen(s.c_str(), "r"); 
          fseek(f2, 0, SEEK_SET);                  
          fread(&amp;infoma, sizeof(infoma), 1, f2);               
          fclose(f2);                          
  
      }
  </code></pre>
  
  <p>Thank you for your help. I have no clue where my problem is and as I said I am searching for hours. </p>
  
  <p><strong>EDIT:</strong>
  The file gets opened I tryed it (f2 is true!).</p>
  
  <p><strong>EDIT":</strong>
  ERRNO = 0 !!!</p>
  
  <p>SEE HERE: </p>
  
  <pre><code>ostringstream Str;
  Str &lt;&lt; errno;   
  infoma.ID = Str.str(); 
  </code></pre>
  
  <p>Just did this to see the result of errno in my wxtextlabel.</p>