954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Opening a File using SYSTEM

Hey guys. Im trying to open a file the user entered.

cout<<"Please enter the file name";
cin>>name;
cout<<"Do you want to open the file? [yes] or [no]"<<endl;
cin>>pick;
if(pick=="yes")			
system("C:\\wmplayer.exe fname");
else 
cout<<"Good bye";


How do i get the value thats in fname to be printed their so it can open the file.
Lets say the value of fname was movie.avi. The user entered movie.avi and fname is a string that stores that value

slygoth
Light Poster
43 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Concatenate "C:\\wmplayer.exe " and fname into a char* and use that variable.

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 
Concatenate "C:\\wmplayer.exe " and fname into a char* and use that variable.

So then ill have

char *fileopen;
fileopen=&fname;


?

slygoth
Light Poster
43 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Anyone else has a suggestion?

slygoth
Light Poster
43 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Im not understanding what walt wants me to do. If i point the char to the string its gong to give me an error. Can someone else please give me another suggestion been trying to work something out for hours. The entire code im trying to build is complete but this part is giving me hell

slygoth
Light Poster
43 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

duplicate thread. See answer here

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Thread closed!

Please follow any further discussion here

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: