Ok so I'm actually in class right now but no matter how many times I raise my hand my teacher decides to just walk past me. I think it's because I am using Ubuntu and she seems to have absolutely no clue how to work with anything in Unix. Anyway here is my code:
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main ()
{
int num;
ifstream numbers("numbers_in.ptd");
ofstream blank("numbers_out.ptd");
if (!numbers_in.is_open())
{
cout << "Cannot open numbers_in" << endl;
exit (1);
}
else (!numbers_out.is_open());
{
cout <<"Cannot open " << endl;
exit (1);
}
numbers >> num;
while (numbers >> num)
{
cout << num;
}
while(!numbers.eof())
{
blank << num << endl;
numbers >> num;
}
blank.close ();
numbers.close ();
return 0;
}
When I try to compile I get the error:
Code:
HW4_2A.cpp: In function ‘int main()’:
HW4_2A.cpp:11: error: ‘numbers_in’ was not declared in this scope
HW4_2A.cpp:16: error: ‘numbers_out’ was not declared in this scope
The guy beside me is on Mac OS and he said something about having to find where the editor saves the actual program. I'm not sure what he meant or if this even works the same way in Ubuntu. I have created and saved the files numbers_in and numbers_out in the same folder that I saved the code (HW4_2A.cpp) and when I compile any other program they are put into the same folder as the .ccp file. So I'm not sure why it is saying they are not declared when they are in fact in the same folder. Once again I am on Ubuntu and I am using gedit to write the code and terminal to compile it. Thanks in advance for any help as my teacher is avoiding me like the plague.