C输入输出的一个例子(不受Enter键影响)

    int guess = 1;             
	char yn;
	printf("enter a number:");
	printf("Uh....is %d?\n",guess);
	while((yn= getchar()) != 'y')
	{
		if( isalpha(yn))
		{
			printf("well,then ,is it %d?\n",++guess);
		}
		else
		{
			printf("input error\n");
			if(yn == '\n')
				continue;
		}
		    while(getchar() != '\n')
			   continue;                   //跳过输入行剩余的部分
		
	}
	printf("I knew I could do it !\n");
 

你可能感兴趣的:(例子)