English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-08-19 09:13:39 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

#include

void playgame();
void loadgame();
void playmultiplayer();

int main()
{
int input;

printf( "1. Play game\n" );
printf( "2. Load game\n" );
printf( "3. Play multiplayer\n" );
printf( "4. Exit\n" );
printf( "Selection: " );
scanf( "%d", &input );
switch ( input ) {
case 1: /* Note the colon, not a semicolon */
playgame();
break;
case 2:
loadgame();
break;
case 3:
playmultiplayer();
break;
case 4:
printf( "Thanks for playing!\n" );
break;
default:
printf( "Bad input, quitting!\n" );
break;
}
getchar();

}
the errors are:
swirch.obj : error LNK2001: unresolved external symbol _playmultiplayer
swirch.obj : error LNK2001: unresolved external symbol _loadgame
swirch.obj : error LNK2001: unresolved external symbol _playgame

2006-08-19 10:50:30 · update #1

3 answers

Those are linker errors.
You have declared three functions:
void playgame();
void loadgame();
void playmultiplayer();

But you have never created bodies for them.

The linker is telling you that you have called these routines, but it doesn't know were they are to insert the appropriate addresses.

If you have defined these in other files, then the problem is that the aren't included in your project. i.e. don't appear in the make file.

If you started out by creating a new project, you can add the files to the project by clicking on Project/Add to Project/files. Then select the files you need to add.

If you didn't start out by creating a project, click File/New/(Project Tab) and select Win32 Console application. Set the target directory to be somewhere other than where your existing code is located.
On the next screen select "A simple application".
That will give you a file with an empty main() where you can swap in your code. Then you can easily add other files to the project.

2006-08-19 10:22:28 · answer #1 · answered by rt11guru 6 · 1 0

well, i dont know what complier u r using, but usualy, when u choose to make a new project, u can check a box to choose c rather than c++ , or something liek that. most c++ compliers have a c option, but using c when u can write c++ is pritty much pointless

2006-08-19 09:32:06 · answer #2 · answered by Kristofer 4 · 0 0

I couldn't tell you myself, I repair slot machines, but I'm not a computer wiz. Sean I.T. (C) has covered this subject a few times. You can check his answers in his Q&A page. He has a couple thousand posts, though.
http://answers.yahoo.com/my/profile?show=AA12042975

2006-08-19 09:36:48 · answer #3 · answered by rallsjc 5 · 0 0

fedest.com, questions and answers