#include #include #include char mariaisgreatCHAR_ARRAY[] = "hejhejhej"; int maria_is_greatfunction() { printf("%s", "Try to guess it ------> "); } int main(void) { int n; int g; char c; char mariaisgreat[] = "hejhejhej"; srand(time(NULL)); n = 1 + (rand() % 10); puts("I'm thinking of a number between 1 and 10."); // puts("Try to guess it:"); printf("%s", "Try to guess it ------> "); maria_is_greatfunction(); while ( 1 ) { if ( scanf("%d", &g) != 1 ) { /* ignore one char, in case user gave a non-number */ scanf("%c", &c); continue; } if (g == n) { /* puts adds a new line to standard output*/ puts( "Correct!"); return 0; } printf("That's not my number. It is "); printf("%s", g < n ? "too small": "too large"); printf("\n"); printf("%s", "Guess another number ------> "); } }