Hi.

this code giving compiling error....why :(


#include<iostream.h>
#include<fstream.h>
#include <iomanip>
#include <cwchar>
#include <cmath>
main()
{
ifstream inFile;
char inputFileName[]="Electricity_Bill.txt";
const int MAX_CHAR_TO_READ = 100;
char completeLineText[MAX_CHAR_TO_READ];

inFile.open(inputFileName);

if(!inFile)
{
cout "Can't open input file named " inputFileName endl;
exit(1);
}

while(!inFile.eof())
{
inFile.getline(completeLineText,MAX_CHAR_TO_READ);
cout completeLineText endl;
}
inFile.close();
system("pause");

}
1. Remove the .h from iostream and fstream.
2. You're using cout wrong, you need to use the << operator between stuff to print out.
3. You need to add using namespace std; if you aren't going to specify std::cout, std::endl, std::ifstream, etc.
Last edited on
ok thanx L B..i check it now.
i did as you say..but there is same problem..infact compiling time error is occur....will u solve this? :( tommorrow is ladt date to send it :(
Could you at least copy and paste the errors into your post so we know what exactly the problem is?
I'll give you a hint

It's on this line:main(). Of course any C++ code you look at should have the correct version of this line(Another hint). Also based on the quality of this code, perhaps you should brush up on language basics before you try somthing like file I/O
1 C:\Dev-Cpp\include\c++\3.4.2\iostream:1, from C:\Dev-Cpp\include\c++\3.4.2\iostream from C:/Dev-Cpp/include/c++/3.4.2/iostream:1, from C:/Dev-Cpp/include/c++/3.4.2/iostream
1 C:\Dev-Cpp\include\c++\3.4.2\iostream:1, from C:\Dev-Cpp\include\c++\3.4.2\iostream from C:/Dev-Cpp/include/c++/3.4.2/iostream:1, from C:/Dev-Cpp/include/c++/3.4.2/iostream

and so on...give just 1 type of error.
You have an outdated compiler: http://www.cplusplus.com/articles/36vU7k9E/
i have to download it again(dev)?..i couldn't understand it?
ok dont give ans..i will do it byself..try karti ho.. :(( anyways..thanx 4 guiding me :) L B n king.
Topic archived. No new replies allowed.