Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
18 years ago

[fstream] Cannot opening file

Hi !

Excuse me for my english but I&#39;m a french speaker ! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/unsure.gif

So here is my (simple http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif ) problem : I can&#39;t open a file to write in some bytes ... !

The code used to do that :

...# include <iostream.h># include <fstream.h>
...
void WriteBinData(const char* _FileName)
{
  std::ofstream l_File;
  int l_Counter = 0;
  
  cout << "Opening/creating test file: " << _FileName << "\r\n";
  l_File.open(_FileName, std::ios_base::binary);
  if(l_File)
  {
    for(l_Counter = 0; l_Counter < 8; l_Counter++)
      l_File.write(reinterpret_cast<const char*>(&l_Counter), sizeof(int));
    l_File.close();
  }
  else cout << "\r\n*** Error opening file \"" << _FileName << "\"\r\n";
}

It displays every time the error message ... ! The problem is the same in opening the file in text mode ... !

An idea of the problem ... ?! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/huh.gif

[EDIT]

Altrough the program is continuing after the &#39;l_File.open(...)&#39; instruction, this one is no longer responding ... Because afer this instruction, the FTP server that is running in the same application is not avalaible ... !

[/EDIT]
No RepliesBe the first to reply