hello,can someone shows me how to get open file function,close,print and save functions?i need it so urgent.thax!!
hello,can someone shows me how to get open file function,close,print and save functions?i need it so urgent.thax!!
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);
}
Do you mean with dialog boxes Ferraski? As in Visual C++ or Borland Builder or something? Or do you mean the functional part of it, the actual opening, closing etc.?
Didn't you use that post for another question programmer??
Almosthere
"Technology has merely provided us with a more efficient means for going backwards" - Aldous Huxley
He uses that answer in all of his replies, eventually one of them answers the question
No, I'm just kidding...
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
yes,almost_here.
well,it's some sort of mfc. it's like well,a clicking button like the toolbar there.when u clicked on open,it will open a new and when u clicked on close,it will close the file. it's same like the microsoft word. so,how should i do it? yeah i meant the functional part of it. how the code looks like for it?i am doing the vc++.it's like a dialog boxes. u r right...almost_here
Ah. Then i'm afraid i can't help you, sorry. I don't use windows-dialog controls. I'm sure someone here does more visual app-based developing in VC++ than i do though... I stick to console apps mostly. If it's MFC you're after it's probably dead straightforward too - they're just standard dialogs.
Sorry couldn't be more helpful - check out some VC tutorials and look up "dialog controls" with "save", "open","print". Although "print" is likely to be more difficult - depending on what you want to print.
Actually, forget that last comment. MFC probably does that for you too.
Ah.
"Technology has merely provided us with a more efficient means for going backwards" - Aldous Huxley
it was me who used that code, to reply to someone elses query a while back, im all for sharing the knowledge, but im also for creditting the original author. The code isnt even that good.