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;

Recommended Answers

All 2 Replies

>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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.