Error 87 in release build

This is a discussion on Error 87 in release build within the Windows Programming forums, part of the Platform Specific Boards category; I get an error 87 in release build, but I get no error running my program in debug build. What ...

  1. #1
    Registered User CrissyCrisCris's Avatar
    Join Date
    Aug 2009
    Posts
    13

    Error 87 in release build

    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.

  2. #2
    Registered User CrissyCrisCris's Avatar
    Join Date
    Aug 2009
    Posts
    13
    Nevermind, I figured it out.

    Code:
    //I just had to add.
    szNote[4] = '\0';
    szLength[4] = '\0';
    szDelay[4] = '\0';

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,918
    >> strcmp(szPlayPath, "\\");
    >> strcmp(szPlayPath, szPlay);
    These don't do anything.
    I'd also advise on using std::getline (instead of std::cin.getline) and the accompanying std::string. To copy a string from one to another (C strings), use strcpy. Of course, with std::string, it's just a simple matter of assignment.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    ERROR_INVALID_PARAMETER
    87 (0x57)
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PlaySound
    By cangel in forum C++ Programming
    Replies: 16
    Last Post: 10-08-2009, 06:29 PM
  2. How to build, run Boland C++ 6 source file via VS2005?
    By userpingz in forum C++ Programming
    Replies: 2
    Last Post: 05-21-2009, 04:25 AM
  3. Replies: 0
    Last Post: 10-07-2008, 01:09 PM
  4. Problem in the optimized / release build
    By g4j31a5 in forum C++ Programming
    Replies: 10
    Last Post: 10-10-2006, 07:32 AM
  5. Boom, Headoshot!!
    By mrafcho001 in forum A Brief History of Cprogramming.com
    Replies: 50
    Last Post: 07-21-2005, 09:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21