I get an error 87 in release build, but I get no error running my program in debug build. What is my problem?
Source:
Code:
#include <windows.h>
#include <iostream>
#include <fstream>
#pragma warning (disable : 4996)
#pragma warning (disable : 4101)
void BeepMacro(int iNote, int iPlay, int iPause)
{
if (Beep(iNote, iPlay) == false)
std::cout << "ERROR: " << GetLastError() << std::endl;
Sleep(iPause);
}
int main()
{
char szFilePath[256];
char szSong[32], szPlay[32], szPlayPath[256];
char szCurrentLine[64];
GetCurrentDirectory(256, szFilePath);
strcat(szFilePath, "\\music.ini");
if (GetFileAttributes(szFilePath) == INVALID_FILE_ATTRIBUTES)
printf("ERROR: music.ini cannot be found.\n");
else
{
GetPrivateProfileString("INFO", "Song", "-Song Title-", szSong, 32, szFilePath);
SetConsoleTitle(szSong);
GetPrivateProfileString("INFO", "TXT", "music.txt", szPlay, 32, szFilePath);
GetCurrentDirectory(256, szPlayPath);
strcmp(szPlayPath, "\\");
strcmp(szPlayPath, szPlay);
if (GetFileAttributes(szPlayPath) == INVALID_FILE_ATTRIBUTES)
printf("ERROR: %s cannot be found.\n", szPlay);
printf("[INFO]\nSONG TITLE: \t%s\nSONG FILE: \t%s\n", szSong, szPlay);
std::ifstream Song(szPlay);
while (Song.eof() == false)
{
Song.getline(szCurrentLine, 64);
char szNote[4], szLength[4], szDelay[4];
szNote[0] = szCurrentLine[0]; szNote[1] = szCurrentLine[1];
szNote[2] = szCurrentLine[2]; szNote[3] = szCurrentLine[3];
szLength[0] = szCurrentLine[5]; szLength[1] = szCurrentLine[6];
szLength[2] = szCurrentLine[7]; szLength[3] = szCurrentLine[8];
szDelay[0] = szCurrentLine[10]; szDelay[1] = szCurrentLine[11];
szDelay[2] = szCurrentLine[12]; szDelay[3] = szCurrentLine[13];
BeepMacro(atoi(szNote), atoi(szLength), atoi(szDelay));
}
}
std::getchar();
return 0;
}
music.ini
[INFO]
Song=Mario Theme
TXT=music.txt
Music.txt
Code:
0660 0100 0150
0660 0100 0300
0660 0100 0300
0510 0100 0100
0660 0100 0300
0770 0100 0550
0380 0100 0575
...
Too long to post the whole thing.
It is suppose to play the Mario theme song and it dose when I run it with debug.