我使用Visual Studio 2013与标准C.
我的程序需要四行才能
{"Analysis 1", "AN 1", 0, 0.0667}输入Fach[0].
我不想浪费这么多行来填充这个数组.
有没有更好的方法将这四行合二为一?
#define _CRT_SECURE_NO_WARNINGS
#include "header.h"
#include <stdio.h>
#include <string.h>
struct sFach
{
char Mod[40]; //Modulbezeichnung
char Ab[5]; //Abkürtzung
int Note; //Note
double Gew; //Gewichtungsfaktor
};
int main()
{
struct sFach Fach[31];
strcpy(Fach[0].Mod, "Analysis 1");
strcpy(Fach[0].Ab, "AN 1");
Fach[0].Note = 0;
Fach[0].Gew = 0.0667;
strcpy(Fach[1].Mod, "Algebra");
strcpy(Fach[1].Ab, "AL");
Fach[1].Note = 0;
Fach[1].Gew = 0.0889;
return 0;
}
Run Code Online (Sandbox Code Playgroud)