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>


char name[100];
char sal[100];
char dept[100]; 
ifstream infile;
char filename[]="kashif.txt";;
if (!infile)
   cout<<"There is some error in opening the file";
   while (!infile.eof())



Program Output: There is some error in opening the file

What compiler are you using? fstream.h and iostream.h are big no no's. It should be

#include <iostream>
#include <fstream>

Also I'm not seeing a using namespace std; . Does this actually compile?