I need help with this program. I know the file is opening but I'm not sure how to edit the numbers and stuff that is in the file. This is what I have so far. Code: #include <fstream> #include <iostream> #include <cstdlib> int main() { using namespace std; ifstream input; ofstream output; input.open("input.txt"); if (input.fail()) { cout<<"Input file opening failed.\n"; exit(1); } output.open("grade.txt"); if (output.fail()) { cout<<"Output file opening failed.\n"; exit(1); } input.close(); output.close(); return 0; }
If you want to read data from input.txt into variable 'v' and write it out to grade.txt, use: Code: input >> v; output << v; For multiple variables just use the same as you would for cin/cout, i.e.: Code: input >> v1 >> v2 >> v3; output << v1 << v2 << v3; // may need to add spaces ...<<v1<<" "<<v2...