In addition to
Rick remarks,
Quote:
if(yesman == 'yes'){
That's not the correct way to compare
C
strings (and
'yes' is not a valid string literal), you should use the
strcmp (or strncmp) function[
^].
Try
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char yesman[256];
printf("Are you a yes man? ");
if ( scanf("%s", yesman) == 1)
{
if( strcmp( yesman, "yes") == 0)
{
printf("It is bad to be a yes-man.\n");
}
else if( strcmp(yesman, "no")==0 )
{
printf("Good.\n");
}
else if( strcmp(yesman, "No.")==0)
{
printf("Good, and you can spell at that.\n");
}
else
{
printf("Invalid Operator\n");
}
}
return 0;
}