ifstream

This is a discussion on ifstream within the C++ Programming forums, part of the General Programming Boards category; how can i use ifstream to check whether the file exists?...

  1. #1
    Registered User cppdude's Avatar
    Join Date
    Jan 2002
    Posts
    62

    ifstream

    how can i use ifstream to check whether the file exists?

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Try to open it.

  3. #3
    Registered User cppdude's Avatar
    Join Date
    Jan 2002
    Posts
    62
    yes but i need the code to check if its open!

  4. #4
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Code:
    	ifstream is("file.txt");
    
    	if(!is)
    		cerr << "Error Opening File\n";

  5. #5
    Registered User cppdude's Avatar
    Join Date
    Jan 2002
    Posts
    62
    cheers mate

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple ifstream Question
    By Paul22000 in forum C++ Programming
    Replies: 8
    Last Post: 12-05-2008, 04:34 PM
  2. store data from ifstream and store in link list
    By peter_hii in forum C++ Programming
    Replies: 2
    Last Post: 10-26-2006, 08:50 AM
  3. ifstream
    By Wraithan in forum Tech Board
    Replies: 3
    Last Post: 09-24-2006, 01:26 AM
  4. ofstream and ifstream for searching and writing
    By johnnyd in forum C++ Programming
    Replies: 6
    Last Post: 03-17-2003, 07:34 AM
  5. Ifstream Problems
    By IlUomo in forum Windows Programming
    Replies: 1
    Last Post: 04-24-2002, 12:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21