I got it to input the numbers from a text file and i want output the average in another text file but it does not work. However when i output inside c++ its works.
mmm... Then I can't help you. I suggest you paste my code and run it .
May be we should go back and try this:
Can you run this code?
Does it work??
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include <fstream>
usingnamespace std;
int main() {
ofstream test;
test.open("Testing.txt");
test << "If you see this on the file, this works";
cout << "Done" << endl;
}
there we go... so does it ouput "done" on the screen?
Do you have permission to create files in the directory where you are trying to?
Now this is more interesting:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <fstream>
usingnamespace std;
int main() {
ofstream test;
test.open("Testing.txt");
if (test.is_open()){
test << "If you see this on the file, this works";
cout << "Done" << endl;
}
else {
cout << "Could not open file Testing.txt" << endl;
}
return 0;
}