小编Dan*_*oos的帖子

在 printf 中的引号(格式)之间添加逗号会改变输出吗?

我面临着一个非常奇怪的问题,我只能在 Linux 上产生。我确实在互联网上找不到类似的东西,但如果我的搜索技巧不够好,如果这是任何问题的重复,我深表歉意。

采用下面的最小可行代码:我在仍然遇到问题的情况下尽可能地减少了代码。

#include <stdio.h>

#define MAX 10
#define MAXNAME 30

typedef struct sup{
    int rating;
    char supName[MAXNAME];
}sup;

typedef struct spec{
    char name[MAXNAME];
    float width;
    float height;
    float depth;
    char material[MAXNAME];
    sup supvisor[MAX];
}spec;

int read_Supervisors(char fileName[], spec *specread){
    int i=0;

    char buffer[MAX];
    FILE *supervisors = fopen(fileName, "r");

    while (i < MAX && fgets (buffer, sizeof(buffer), supervisors)) {

        if(sscanf(buffer, "%19s %d", specread->supvisor[i].supName, &specread->supvisor[i].rating) == 2){
            i++;}}

    fclose(supervisors);

    return i;
}

void read_Specs(char fileName[],spec *spec1){
    FILE *specs = fopen(fileName, …
Run Code Online (Sandbox Code Playgroud)

c linux terminal scanf line-endings

5
推荐指数
1
解决办法
121
查看次数

标签 统计

c ×1

line-endings ×1

linux ×1

scanf ×1

terminal ×1