Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Need help with opening a file in msdos (http://www.go4expert.com/forums/help-file-msdos-t2897/)

lpd1 7Feb2007 15:01

Need help with opening a file in msdos
 
Hi

I am programming in c++ and i want to open a .xml file but i want the user to by himself enter the name of thefile he wants to open can someone please tell me what code i should use or even maybe print it in a reply to me thanks

lpd1

shabbir 7Feb2007 17:05

Re: Need help with opening a file in msdos
 
You should use the scanf to take the input as filename and use the fopen to open the file and fread to read the file and display it to the user.

DaWei 7Feb2007 17:32

Re: Need help with opening a file in msdos
 
I presume you mean console/command window when you say "MSDOS". If not, you have an ancient system whose utility in learning will be minimal.

You can get the name from argv if the user provides it on the command line. Since you're using C++, I would recommend you forego C operations like fopen, fgets, scanf, and fread. Use the C++ wrapped stream I/O for greater flexibility and robustness.


All times are GMT +5.5. The time now is 23:46.