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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
After 36 years programming, I still do it.
But as you gain experience, you immediately recognize the causes of more and more errors.
#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_st
//------------------------
return 0; // Signal successful program execution
} // End of main()