Thread: file IO problem

  1. #1
    Registered User
    Join Date
    Dec 2001

    Angry file IO problem

    I'm having trouble opening a file in my atm program. A quick rundown:

    So far, my program opens a file when the program executes with a list of usernames and pin numbers. After it reads the contents of the file, it asks the user for his username. If there is a match, it asks for his pin number to complete the validation. Then, another function takes the person's username (I used the variable "bankId"), adds the extension ".dat" and should then open the file called 'username'.dat (Username being the variable bankId)

    The file is not being opened however. Below is the function that should open the file. I am new to classes and this is my first semester of programming, so I'm hoping it's something minimal that I'm just looking over. If you need more code than what I've posted please let me know. Thanks.

    void customer::openCustomerFile(ifstream& fin) {
       char suffix[5] = ".dat";
       char filename[25];
       strcpy (filename, bankId);
       strcat (filename, suffix);
    filename, ios::in );
             if ( !fin ) {
              cout<< "There was an error opening that file." << endl;

  2. #2
    Registered User
    Join Date
    Dec 2001
    I'm not sure why my posted added a little smiley face to my code, but the function is called "openCustomerFile".

  3. #3
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Your code looks fine, the problem must be elsewhere.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Problem reading file
    By coder_009 in forum C Programming
    Replies: 10
    Last Post: 01-15-2008, 01:22 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. Totally puzzling IO problem
    By Vorok in forum C++ Programming
    Replies: 5
    Last Post: 01-06-2003, 07:10 PM