0

so foar I've done this much

using namespace std;

int main()
{

//1.Declares an input stream variable named inFile

ifstream inFile;

//2.Opens "indata.txt"

inFile.open("indata.txt");

//3. If input file was not opened Prints "Input file not found"

if (inFile.fail())
{
cout << "Could not open file!" << endl;
return 1;
}

//4.Exits the program

//5.Declares a variable named number that holds whole numbers

int number;

//6.Reads first value from the file into number

//7.While the end of the file has not been reached

//If number is greater than 0 prints the number followed by " is positive"
//otherwise if number is less than 0 prints the number followed by " is negative"
//otherwise prints the number followed by " is zero" reads the next number from the file

//8.Closes the input file
inFile.close();

return 0;

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by Lerner
0

>so foar I've done this much
That's not much considering that the majority of the program's implementation consists of abstract comments. What exactly do you need help with? We're not going to finish this for you, you know.

0

include the iostream and fstream header files at the top of the program.

You can use the ifstream object you declared, inFile, just like you would cin.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.