Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C++ ifstream error

Posted on 2006-10-20
4
Medium Priority
?
982 Views
Last Modified: 2008-02-01
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

0
Comment
Question by:xneo27
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 2000 total points
ID: 17775441
#include <fstream>
0
 

Expert Comment

by:alex_kurumpelil
ID: 17775908
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()
0
 

Author Comment

by:xneo27
ID: 17777135
Thanks cookre, guess it just slipped my mind or I was in too big of a hurry.
0
 
LVL 22

Expert Comment

by:cookre
ID: 17777893
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.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Simple Linear Regression

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question