Thread: reading a file problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    133

    reading a file problem

    Hey guys I am using code that does the following:

    Code:
    cin.ignore(); 
    cin.getline(file, 250);
    
    ifstream test;
    
      test.open (file);
    
    	if (test.fail())
    		{
    		  cout<<"error"<<endl;
    
    		  exit(1);
    	     }
    
    ...
    The problem is that if a file name is entered that does not exist for example c:\\fred.txt the error message will not appear and the txt file fread will be created. Any ideas what I have done wrong?

    Thanks.
    Last edited by 182; 02-12-2006 at 08:47 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. Replies: 20
    Last Post: 06-12-2005, 11:53 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. Problem reading file
    By winsonlee in forum C Programming
    Replies: 2
    Last Post: 04-23-2004, 06:52 AM