void func_guess_number(){
int guess, magic, ret, counter;
counter = 0;
srand(time(NULL));
magic = rand()%100+1;
printf("generate magic is %d.\n", magic);
do{
printf("Please input a number: \n");
ret = scanf("%d", &guess); // 如果输入的是字符就让他继续输入
if (ret != 1){
while (getchar() != '\n'){;}
printf("please input a digital number\n");
continue;
}
counter++;
if (magic > guess){
printf("Wrong, too low.\n");
}
else if (magic < guess){
printf("Wrong, too high.\n");
}
else{
printf("guess right.\n");
}
fflush(stdin);
} while (magic != guess);
printf("guess times is %d.\n", counter);
}