fflush(stdout)什么时候不起作用?

时间:2018-07-13 05:06:39

标签: c linux gcc

第2行的最后%d不执行,第5行的%c在第二次迭代中接受我的第三个输入。

/etc/mysql/my.cnf

输出:

void main()
{
    while(1)
    {

        printf("Enter Name, roll_no, marks of student\n");
        scanf("%s%d%d", s.name, &s.roll_no, &s.marks);// Line 2
        printf("Do You want to add another record Y/N ");   
        fflush(stdout);// Here I am using fflush(stdout) but it works only in first iteration
        scanf("%c\n",&ch);//Line 5  // This works before printf and %d of scanf of line2  is replaced by %c of this scanf
        if(ch=='n')
        {
            break;
        }
        else
        {
            printf("Hi\n");
        }
    }
    fclose(fp);  
}

0 个答案:

没有答案
相关问题