-
help please
This is my first game here is what I have so far.
Code:
#include <stdio.h>
#include <stdlib.h>
void playgame(void);
int main()
{
int input;
printf("1. Play Game\n");
printf("2. quit\n");
scanf("%d", &input);
switch (input)
{
case 1: playgame();
break;
case 2:
return 0;
default:
printf("Bad input quiting...");
system("pause");
}
return 0;
}
void playgame(void)
{
char input[20];
printf("You see a huge mansion, it speaks to in some strange way. Almost as if it were\ncalling you.\n");
printf("north\n");
scanf("%s", &input);
if (input = "north")
{
printf("good\n");
system("pause");
}
}
When I compile it I get the error "incompatible types in assignment". Thanks in advance for what ever help you may offer.
-
if (input = "north")
This line is no good. string compares don't work that way in C.
if(!strcmp(input,"north"))
would work however.
plus this:
scanf("%s", &input);
you don't want the address of "input". You want
scanf("%s",input);
-
-
and for the future, remember it is == in conditional statements... = assigns the value to the variable, == checks if they are equal...