if statement with nested functions will not execute

50 views Asked by At
#include <stdio.h>

main()
{
   char      name[30];
   int       age;

   printf("Please enter your name: ");
   scanf("%s", name);

   printf("How old are you %s: ", name);
   scanf("%d", age);

   if (strcmp(name, "Abs") == 1 && age == 25)
      printf("You are the CHOSEN one!\n");
   else
      printf("You are a wankstain!\n");

   fflush(stdin);
   getchar();
}

The if statement seems to ignore the right answer, i have also tried to put the age in brackets to no avail.

1

There are 1 answers

1
Ed Heal On
  1. Why not read the manual page for strcmp. You been to check for zero.
  2. Ditto for scanf - it does return a value that needs to be checked.
  3. Use braces - prevents problems in the future.
  4. You do not need to flush stdin.

(see http://linux.die.net/man/3/strcmp and http://linux.die.net/man/3/scanf)