Need help with opening a file in msdos

Newbie Member
7Feb2007,15:01   #1
lpd1's Avatar
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
Go4Expert Founder
7Feb2007,17:05   #2
shabbir's Avatar
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.
Team Leader
7Feb2007,17:32   #3
DaWei's Avatar
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.