My Question: I have created a text file named it kashif.txt and i have placed this file in the same folder where .exe and .ccp of this program is placed but file is not opening.
My code is as under.
#include <fstream.h>
#include<iostream.h>
main()
{
char name[100];
char sal[100];
char dept[100];
ifstream infile;
char filename[]="kashif.txt";
infile.open(filename);
if (!infile)
{
cout<<"There is some error in opening the file";
}
while (!infile.eof())
{
infile>>name>>sal>>dept;
cout<<name<<"\t"<<sal<<"\t"<<dept<<"\n";
}
infile.close();
}
Program Output: There is some error in opening the file