Monday, 30 January 2012

Program Of File Read Opreation In C++



#include <iostream.h>
#include<conio.h>
main()

{
    clrscr();
    char FirstName[30], LastName[30];
    int Age;
    char FileName[20];

/*

    cout << "Enter First Name: ";

    cin >> FirstName;

    cout << "Enter Last Name:  ";

    cin >> LastName;

    cout << "Enter Age:        ";

    cin >> Age;



    cout << "\nEnter the name of the file you want to create: ";

    cin >> FileName;


    Students << FirstName << "\n" << LastName << "\n" << Age;

*/

    cout << "Enter the name of the file you want to open: ";
    cin >> FileName;
    ifstream Students(FileName);
    Students >> FirstName >> LastName >> Age;
    cout << "\nFirst Name: " << FirstName;
    cout << "\nLast Name:  " << LastName;
    cout << "\nEnter Age:  " << Age;
    cout << "\n\n";
getch();

}


No comments:

Post a Comment