How do you make the program open up a file and then save a file?
thx.
How do you make the program open up a file and then save a file?
thx.
Code:#if _emo #define stereo_type_i_dislike #endif
scratch the above;
what is the prototype for:
loadDOC (filename);
????
Code:#if _emo #define stereo_type_i_dislike #endif
bluehead, whatever happened to xterria? arent you two friends or something?
I haven't seen him in a while, have you?
Code:#if _emo #define stereo_type_i_dislike #endif
Not sure if this is what your after, but in its most basic form, i'd do it like this:
#include <fstream.h>
main()
{
char ch;
char filename[20] = "c:test.txt";
int mode = ios:ut;
fstream fout(filename, mode );
cout << "Ready for input, use CTRL+Z to end" << endl;
while ( cin.get( ch ) )
{
fout.put( ch );
}
fout.close();
return(0);
}
fout.close(); is important, miss it and you could **** up your whole hd.
to open the file:
#include <fstream.h>
main()
{
char ch;
char filename[20] = "c:test.txt";
int mode = ios::in;
fstream fin(filename, mode );
if (!fin)
cout << "Unable to open file";
while ( fin.get(ch) )
{
cout << ch;
}
fin.close();
return(0);
}