How to read WAV from ROOT folder

Hi this is my first post and i hope it is easy to understand

I use dev bloodshed c++
I use windows xp 32bit
I'm working on a text based video game in console application.
i started a new project to test the ability of playing sounds to add into the main program afterwords. I have the Playsound command wrking but i need to be able to have the program able to read the WAV files from the folder that the program is in. So instead (for example) of having:
PlaySound("C:/Windows/Media/test1.wav", NULL, SND_FILENAME);
i need a path that doesn't use anything direct, i just need it to say that the file is in the project folder. I tried : PlaySound("/test1.wav", NULL, SND_FILENAME); but it only does the C drive; is thier something that can say the root folder?
Here's my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<windows.h>
#include<mmsystem.h>
#include<stdlib.h>

using namespace std;
int main (char argc)
{
    
      PlaySound("/test1.wav", NULL, SND_FILENAME);
      system("pause");
      return 0;
}

//reads from C:/test1.wav// 



Any suggestions would be appreciated!





Last edited on
hehe, talk about complicated! You missed the simplest: PlaySound("test1.wav", NULL, SND_FILENAME);. That should play the sound from the executable's working directory.
Basically / return the root directory C:/ in your case although you don't want the root one. You want the pwd (present working directory).
I think @webJose suggestion would be satisfactory
Thanks a lot! Works great!
Just a note (even though you've figured it out already), you can also use .// to represent the current directory. This is useful for a few things:

1. Lets say that our excecutable is in c:/dev/bin, and our sound file is in c:/dev/bin/sound, we can go looking for that other file using this:

PlaySound("..//sound//test1.wav", NULL, SND_FILENAME);

Note that I use the / character twice as it would otherwise represent a pre-processing command and would not be recognized correctly.

2. Lets say that our excecutable is in c:/dev/bin and our sound file is in c:/dev/. It is a directory up from the excecutable. We can use:

PlaySound("..//..//test1.wav", NULL, SND_FILENAME);

continuing to use ..// will move up one directory each time.
Thanks
Topic archived. No new replies allowed.