Is one way better than the other, or a matter of preference? |
Well, I think it depends, initially I thought it was better to use the long file name including the drive full path. That does mean you could copy the exe anywhere you liked on your machine, and it would still work.
But what if you wanted to share the program with a friend? They would not have the same drive/folder structure on their own machine. So in this case it would make more sense to go back to your original code with the short (relative) filename. Then you could share the program with others more easily. For example you might put the three files (.exe and two sound files) inside a single .zip file for easy transport. Your friend then just unzips the contents into any folder they wish.
There is another way, using a resource file. This way, the sound files can stored inside the exe file, so the end result is a single file, but it is much larger because it contains the wave files as well as the executable program. This can also be convenient. The advantage/disadvantage is that because there is just one file, the only way to swap the sound files is to rebuild the program, rather than just replacing the sound file later.
Simple example using a resource file:
http://www.cplusplus.com/forum/general/188070/#msg916002
With Code:Blocks, if you just add the
sounds.rc
file to the project along with
main.cpp
, then the build process should work ok.