相关疑难解决方法(0)

fflush(stdin)函数不起作用

我似乎无法弄清楚这段代码出了什么问题:

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>


#define MAX 100
#define TRUE 1
#define FALSE 0

char sect_cat;
char customer_name[MAX];
char customer_number[MAX];      /* error handling is easier */

int prev_unit = 0;
int current_unit = 0;
int consumed = 0;
int set = FALSE;

float init_bill;
float tax;
float total_bill;


    void get_userinfo()
    {

            printf("Enter sector category: ");
            scanf("%c", &sect_cat);
        printf("Enter customer name: ");
        fflush(stdin);
        scanf("%sn", &customer_name);

        set = FALSE;
        while (set == FALSE)
        {
            printf("Enter customer number: "); …
Run Code Online (Sandbox Code Playgroud)

c stdin fflush

4
推荐指数
2
解决办法
7478
查看次数

标签 统计

c ×1

fflush ×1

stdin ×1