Thread: Filepointer

  1. #1
    newguy27
    Guest

    Angry Filepointer

    WHAT IS FILE POINTER USED FOR??

    char * FileName = "input.dat";

    inFile.open(FileName);

    if(!inFile)
    {
    cout<<"Sorry cannot open file"
    exit(0);
    }

    why is this unacceptable
    ifstream readme;

    char ch;
    char newch;

    readme.open("output.dat");
    if (!readme) {
    //Unable to open file for output( eg, readonly, no disk space)
    cerr<<"Unable to open file\n";
    exit(0);

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Do the files you are trying to read exist? Hint: use code tags.

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    I dont really see whats unaccpetable here...

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I think I know the problem. You use ofstream to write a file not ifstream.

  5. #5
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    What do you mean by unacceptable, are you having a compiler error, or runtime error or what?
    none...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. n00b question.... dat file related
    By hobbes67 in forum C Programming
    Replies: 7
    Last Post: 06-24-2005, 11:39 AM
  2. filepointer
    By stormbringer in forum C Programming
    Replies: 6
    Last Post: 11-03-2002, 04:33 PM
  3. how to get the output of a non-stop process?
    By dkt in forum C Programming
    Replies: 1
    Last Post: 04-27-2002, 11:18 AM
  4. Files
    By {Dnw} in forum C Programming
    Replies: 10
    Last Post: 08-27-2001, 07:37 AM