File I/O

This is a discussion on File I/O within the C++ Programming forums, part of the General Programming Boards category; ok I want to make a program that allows you to login and sign up. I have it all done ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    208

    File I/O

    ok
    I want to make a program that allows you to login and sign up.
    I have it all done except for I want to make it so when you sign up each time it creates a different file. I don't want to specify the file name I want the file to be user name the person inputs when they are signing up I tried this

    ofstream a_file(name".txt);

    and

    ofstream a_file(name>>".txt);

    and this

    char txt[6]=".txt"; ................
    ...............ofstream a_file(name>>txt

    and

    ofstream a_file(nametxt);

    I have all the other code there I just didn't want to include it all.
    well I am pretty much baffled so please can someone out there help me. Thanx

    KAS2002

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    From what you've posted I think strcat should do the trick. Something like this:

    Code:
    char name[12];
    cout<<"Enter username (must be 8 or less characters):"<<"\n"
    cin>>name;
    strcat(name,".txt");
    ofstream a_file;
    a_file.open(name);
    Last edited by jdinger; 05-31-2002 at 02:02 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-30-2004, 11:21 PM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM
  5. advice on file i/o
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 04:56 AM

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