State the output File Operation's 5

/*
    State the output
*/
#include<iostream>
#include<fstream>
#include<string.h>
#include<cctype>
using namespace std;

int main()
{
    ifstream ifile;
    ifile.open("text.txt");

    cout<<"\n Reading data from a file:- ";
    int c=ifile.peek();

    if(c==EOF)
        return 1;

    if(isdigit(c))
    {
        int n;

        ifile>>n;
        cout<<"\n Data in the file: "<<n;
    }
    else
    {
        string str;
        ifile>>str;
        cout<<"\n Data in the file: "<<str;
    }

    ifile.close();

    return 0;
}

Previous
Next Post »