looksy

This is a discussion on looksy within the C++ Programming forums, part of the General Programming Boards category; how to append this info instead of overwriting existing file #include<iostream.h> #include<fstream.h> void main() { char first_name[25]; char last_name[25]; char ...

  1. #1
    Unregistered
    Guest

    Talking looksy

    how to append this info
    instead of overwriting existing file


    #include<iostream.h>
    #include<fstream.h>

    void main()
    {
    char first_name[25];
    char last_name[25];
    char subject[15];
    char sector;

    //now setup a file stream
    //firstly a name and input file

    ifstream infile;

    //now associate it with a file

    infile.open("B:\\persons.txt");

    infile>>first_name;
    infile>>last_name;
    infile>>subject;
    infile>>sector;

    //now read it!!!!

    infile.close();

    //display

    cout<<endl<<"first_name:-"<<first_name;
    cout<<endl<<"last_name:-"<<last_name;
    cout<<endl<<"subject:-"<<subject;
    cout<<endl<<"sector:-"<<sector;



    cout<<endl<<endl;

    }//end program

  2. #2
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133
    >>infile.open("B:\\persons.txt");

    outfile.open("B:\\persons.txt" ,ios::app); //who uses b anymore?

    i think you might have to include <iomanip.h>

    I know this works for output. You do want this to be put "out" in the file right?
    Last edited by ski6ski; 09-27-2001 at 08:41 AM.
    C++ Is Powerful
    I use C++
    There fore I am Powerful

  3. #3
    Unregistered
    Guest
    B:\\ is my internal ZIP drive
    (college computer technologically backwards country[Scotland])

Popular pages Recent additions subscribe to a feed

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