我面临着一个非常奇怪的问题,我只能在 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)