I'm having trouble with some file i/o coding.. I'm not sure why i can't get it to work.
Code:#include <fstream.h> #include <iostream> #include <string.h> #include <cstdlib> #include <stdlib.h> int main() { int aa, bb, cc, a, b, c; aa=1, bb=2, cc=3, a=3, b=1, c=2; ofstream abc; abc.open ( "example.txt" ); abc << aa << " " << bb << " " << cc << endl; abc << "This is a test" << endl; abc.close(); ifstream cba ( "example.txt" ); if ( !abc.is_open() ) { cout << "Nuttin" << endl; } else { cba >> a >> " " >> b >> " " >> c; cout << a << " " << b << " " << c; } cba.close(); return 0; }
sorry its a little long, but i'm lost with this whole file i/o stuff. none of the tutorials or information about it is helping me any.
I have been unable to compile this so that it goes into the else statement under ifstream. and that is as far as i have been able to narrow the problem down.. Thanks if anyone helps..