Thread: Unable to create file

  1. #1
    Registered User
    Join Date
    Aug 2011

    Unable to create file

    Why doesn't the following code create a new file

    int main()
    	std::fstream file;"something.bin",std::ios::binary|std::ios::in|std::ios::out);
    		std::cout<< "unable to open\n";		

  2. #2
    Registered User
    Join Date
    May 2010
    The following code:
    Will open a file if it exists, it will fail to open the file if it does not exist. You will need to use one of the other std::ios flags to get the file to be created, app, or trunc, depending on how whether you want to keep the data if the file exists, or erase the data.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unable to create thread
    By Leojeen in forum C Programming
    Replies: 5
    Last Post: 02-17-2011, 11:06 AM
  2. Unable to create a UDP client from thread?
    By sehang in forum C Programming
    Replies: 9
    Last Post: 12-14-2010, 08:38 AM
  3. unable to create pthreads for chat ap
    By Fillis52 in forum Networking/Device Communication
    Replies: 10
    Last Post: 11-03-2010, 10:11 AM
  4. Unable to create a simple function
    By garg29om in forum C Programming
    Replies: 3
    Last Post: 02-27-2010, 05:17 PM
  5. "mi_cmd_var_create: unable to create variable object"
    By jiapei100 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2010, 04:24 AM