I'm getting alot of errors

Hello

I am trying to make a jukebox that allows the user to select a song from a list of tracks

First of I am trying to get my jukebox to simply just play the songs one after another.

I am a complete beginner, so I don't really know what I am doing, would appreciate some help.

I'm getting quite a few errors, first of, are there any blatent things I have missed out etc

any help will be really appreciated! :)

Here is my code

#include <iostream>
#include <windows.h>
#include <MMSystem.h>
#pragma comment(lib, "winmm.lib")

using namespace std;

void display_menu(void);

void play_song_1();
void play_song_2();
void play_song_3();
void play_song_4();
void play_song_5();
void play_song_6();
void play_song_7();
void play_song_8();

int main ()

int song_1, song_2, song_3, song_4, song_5, song_6, song_7, song_8;

do
{
display_menu()
choice = get_choice();

if (choice == '1')
play_songs(song1, song2, song3, song4, song5, song6, song7, song8);

return0;
}

void display menu()
{
cout<<"\n To play all songs, press '1' and then enter\n";
}

void play_song_1()
{
mcicommandstring(L"play C:\\Desktop\\08 Bankrobber.mp3", NULL, 0, 0);
}

void play_song_2()
{
mcicommandstring(L"play C:\\Desktop\\After Hours.mp3", NULL, 0, 0;
}

void play_song_3()
{
mcicommandstring(L"play C:\\Desktop\\Panic.mp3", NULL, 0, 0;
}


void play_song_4()
{
mcicommandstring(L"play C:\\Desktop\\A Well Respected Man.mp3", NULL, 0, 0;
}


void play_song_5()
{
mcicommandstring(L"play C:\\Desktop\\Sheepskin Tearaway.mp3", NULL, 0, 0;
}



;}
You have several problems with your code. Just to point out a couple that jumped out at me...

Your do loop does not have a closing while condition. I don't see any get_choice() function defined anywhere. None of your function calls to mcicommandstring have a closing ).

And this play_songs(song1, song2, song3, song4, song5, song6, song7, song8); isn't going to work as there is no function that takes those parameters. This function call also doesn't know what song1, song2, etc... is because you defined them as song_1, song_2, etc..

No opening brace for function main. choice is not have any data type and then you're saying if (choice == '1') which indicates a character instead of a number... which won't matter since you never properly defined choice. And you have this ;} that's just hanging out there.... You need to take a step back and focus on c++ fundamentals before getting into Win32.
Last edited on
I've changed my code to this #include <iostream>


#include <windows.h>
#include <MMSystem.h>
#pragma comment(lib, "winmm.lib")

using namespace std;

void play_songs(int song1, int song2, int song3, int song4, int song5);

void get_choice();

void display_menu();




int main ();

{
char choice;
int song1, song2, song3, song4, song5

do
{
display_menu()
choice = get_choice();

if (choice == '1')
play_songs(song1, song2, song3, song4, song5);

while

return 0;
}

void display menu()
{
cout<<"\n To play all songs, press '1' and then enter\n";
}

void play_song1()
{
mcicommandstring("play C:\\Desktop\\08 Bankrobber.mp3", NULL, 0, 0);
}

void play_song2()
{
mcicommandstring("play C:\\Desktop\\After Hours.mp3", NULL, 0, 0);
}

void play_song3()
{
mcicommandstring("play C:\\Desktop\\Panic.mp3", NULL, 0, 0);
}


void play_song4()
{
mcicommandstring("play C:\\Desktop\\A Well Respected Man.mp3", NULL, 0, 0);
}


void play_song5()
{
mcicommandstring("play C:\\Desktop\\Sheepskin Tearaway.mp3", NULL, 0, 0);

}

return 0;
}

and I am getting this error : error C2447: '{' : missing function header (old-style formal list?)

What do I need to change?
When you post code, wrap it in [CODE] tags (ie highlight it then click the # on the right of the text box)

Read up on do/while loops. Your format is wrong.

You declared but never defined the play_songs function, what is it supposed to do? also you never declared play_song_6 play_song_7 play_song_8 functions.

as far as I've read, mmsystem.h/mcicommandstring() is only for win32 applications, not for console/DOS apps.

Do you have any programming experience or is this your first project?
I'm doing a win32 application.

I have no programming experience, this is my first project.

I have no idea on what to do :(

do you fancy helping me? How do I declare the play_songs functions

I basically just want my programme to play the 5 tracks in a row.
Well for starters, the most simple GUI would look something like the following (pulled straight from Dev-C++ template)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <windows.h>

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Windows App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}


That will give you a blank window 544 pixels wide and 375 pixels high with the title "Windows App". No menu's, no buttons, just a grey box on your screen.

I'd suggest trying some of the "Beginner Exercises" http://www.cplusplus.com/forum/articles/12974/ at very least before trying your jukebox

However if you want to still jump in the deep end, http://www.winprog.org/tutorial/ has a good tutorial for Win32 API
Topic archived. No new replies allowed.