1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
/* scanf example */
#include <stdio.h>
#include <windows.h>
int main ()
{
const WORD colors[] =
{
0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F,
0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6
};
HANDLE hstdin = GetStdHandle( STD_INPUT_HANDLE );
HANDLE hstdout = GetStdHandle( STD_OUTPUT_HANDLE );
WORD index = 0;
// Remember how things were when we started
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo( hstdout, &csbi );
// Tell the user how to stop
SetConsoleTextAttribute( hstdout, 0x07 );
char str [80];
int i;
printf ("What's ur name: ");
scanf ("%s",str);
printf ("U got nice name ");
SetConsoleTextAttribute( hstdout, 0x0A );
printf ("%s \n");
SetConsoleTextAttribute( hstdout, 0x07 );
printf ("but say %s how old are you?");
scanf ("%d",&i);
if ( i < 10 or i == 10 ) {
printf ("U are pretty young\n");
}
else if ( i > 10 and i < 100 ) {
printf ("You are pretty old \n");
}
else {
printf ("Now u lie\n \n");
}
printf ("Leave? [Y]");
scanf ("%e",str);
return 0;
}
|