using namespace std;
in_stream.open("C:\Documents and Settings\Administrator\Desktop\HW\HW4\hw4pr2input.txt");
cout << "Input file opening failed.\n";
cout << "Output file opening failed.\n";
int first, second, third;
in_stream >> first >> second >> third;
out_stream << "the sume of the first 3\n"
<< "numbers in the input\n"
<< "is" << (first + second + third)
We understand that much, but you have provided very little information.
Presuming you have checked that
(1) The file path is correct
(2) All \s are written as \\
(3) There are no non-ASCII characters in the filename or anything else that is messing with it
(4) The file does, in fact, exist before the program runs
Then I think you ought to check the file permissions. Does your program have access rights to open a file on your desktop? Does another process have the file opened or locked in some way?
while your code is valid Drakon, there are shortcuts that do the samething that make it easier to read. because every condition is resolved to either true (and thusly will execute) or false (and the code will be skipped). so you could actually do if(in_stream.fail()) which is the same as your condition. lets say you wanted to test if it returned false (ie in_stream.fail() == false) that can be short cutted to if(!in_stream.fail()).
oh no if thats your way thats fine. if you cant see it (and maybe its just this text not saying you have bad eyesight) then you can write it that way. its just good to know for when you have long conditions