Hi folks,
Im' a C newbie and I am working on some sample code. (please see below)
Code:
#include <stdio.h>
main()
{
int mymood;
char type;
printf("happy or sad [h/s]: ");
scanf(" %c", type);
printf("type = %c\n", type);
mymood = type == 'h';
if (mymood)
printf("My mood is happy\n");
else
printf("My mood is sad\n");
getchar();
}
it compiles pretty well but when i try to run it and pick either 'h' or 's' it coredumps.. and I can't get it to work. =/
any help would be awesomely appreciated.
thanks,
pfu