Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
Its been couple of times that i have noticed this thing. I wanted to play a song by writing a DOS command in my c++ program which is system("start C:\temp\song.mp3"). When,i complied the code only the C drive opens up but it doesn't play the song. I typed the command separetly in my command prompt window and the song opens up. I also tried to open folders from c++ by typing in DOS commands such as system("start C:\temp"). I noticed that only the C folder opens up and any command past beyong C doesn't execute at all. I was wondering if such commands are not applicable in c++ or may be i am making a mistake somewhere. I was wondering other than importing external libraries in c++ to play a song(which i tried before and it worked), is there any way i can play a song by writing in DOS commands in my c++ program and making it play a song or open a folder. Thanks.
Posted
Comments
[no name] 3-Sep-14 21:13pm    
In C languages you generally have to escape the \ character. Your program sees that path as "C:empong.mp3".Try C:\\temp\\song.mp3
Sergey Alexandrovich Kryukov 3-Sep-14 21:34pm    
I don't think that this actually was a problem, because the could would not even compile. The problem is that word "start". I answered, please see.
—SA
Sergey Alexandrovich Kryukov 3-Sep-14 21:27pm    
Where did you find such thing as "DOS"?! What do you call "DOS command", exactly? There is no such thing. :-)
Who gave you this most weird ides, to use the word "start"? What do you think it should mean?
—SA

1 solution

You did not explain how exactly you tried to invoke "start someFile.mp3", but you should not use this word, "start". Remove it. It is specific only for batch files and means that the shall should start some application and continue without waiting for the moment of time when the process is complete.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900