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

Recommended Answers

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

Jump to Post

duplicate thread. See answer here

Jump to Post

All 6 Replies

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

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

So then ill have

char *fileopen;
fileopen=&fname;

?

Anyone else has a suggestion?

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

duplicate thread. See answer here

Thread closed!

Please follow any further discussion here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.