Thread: help please

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    2

    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.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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);
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    2

    Talking

    Thanks alot

  4. #4
    plzduntlakliekthiskthx
    Join Date
    Oct 2002
    Posts
    138
    and for the future, remember it is == in conditional statements... = assigns the value to the variable, == checks if they are equal...

Popular pages Recent additions subscribe to a feed