Link to home
Start Free TrialLog in
Avatar of xneo27
xneo27

asked on

C++ ifstream error

Heres my code:

using namespace std;                  // Global using directive
#include <iostream>                        // Header file for cout and endl
#include <iomanip>                        // Header file for I/O manipulators

int main()                                    // Start of main() function
{
string source;                              // variable for the input file
int numChar;                              // variable for number of characters

cout << "Enter the name of the source program file now: ";            //Prompt user
cin >> source;
cout << endl << endl;

//-------------------INPUT---------------------

ifstream inputfile (source);


//----------------------------------------------

return 0;                                    // Signal successful program execution

}  // End of main()








Heres my errors:

"Program06.cpp", line 28: Error: The type "std::ifstream " is incomplete.
"Program06.cpp", line 28: Error: The type "std::ifstream " is incomplete.
2 Error(s) detected.



Can anyone tell me how to fix this error

ASKER CERTIFIED SOLUTION
Avatar of cookre
cookre
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alex_kurumpelil
alex_kurumpelil

Was able to compile with VC++ 6.0

#include <iostream>                    // Header file for cout and endl
#include <iomanip>                    // Header file for I/O manipulators
#include <fstream>

using namespace std;               // Global using directive

int main()                              // Start of main() function
{
char szsource[256] = {0};              // variable for the input file
int numChar;                         // variable for number of characters

cout << "Enter the name of the source program file now: ";          //Prompt user
cin >> szsource;
cout << endl << endl;

string source = szsource;
//-------------------INPUT---------------------

ifstream  inputfile;
inputfile.open(source.c_str());


//----------------------------------------------

return 0;                              // Signal successful program execution

}  // End of main()
Avatar of xneo27

ASKER

Thanks cookre, guess it just slipped my mind or I was in too big of a hurry.
That happens to all of us.  
After 36 years programming, I still do it.
But as you gain experience, you immediately recognize the causes of more and more errors.