fflush() is not working in Linux

前端 未结 9 831
后悔当初
后悔当初 2020-12-08 05:43

I used the fflush() in Linux GCC but it did not work. Are there any alternatives for that function? Here is my code:

#include
void main()
{
           


        
9条回答
  •  感动是毒
    2020-12-08 06:40

    #include
    int main()
    {
    char ans='y';
    int a;
    while(ans=='y'||ans=='Y')
        {
    
         printf("Type a number:-");
         scanf("%d",&a);
         printf("square of number = %d\nwant to enter 
         number again(y/n)?\nANS=",a*a); 
         scanf("%s",&ans);//use %s in place of %c
         }
    return 0;
    }
    

提交回复
热议问题