Solved

C++ ifstream error

Posted on 2006-10-20
4
973 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android development question 2 109
VB.net and sql server 4 66
Bot application - advice 3 80
How to properly export data from two SAS datasets to one XML data file? 5 46
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

734 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