Need help with opening a file in msdos

lpd1's Avatar
Newbie Member

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

shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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's Avatar, Join Date: Dec 2006
Team Leader
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.