+ 2
ANY wrong to C Code ?#Sequential File Access in C Programming
#include<stdio.h> #include<string.h> typedef struct { char nim[10]; char nama[100]; char nilai[2]; } nilaimatkul; main() { nilaimatkul rekaman; FILE *arsipmatkul; arsipmatkul = fopen("arsipmatkul.dat","w"); printf("tuliskan rekaman satu per satu:\n"); printf("input nim:\n"); scanf("%s",&rekaman.nim); while(strcmp(rekaman.nim,"XXXXXX")!=0) { /* proses */ printf("input nama:\n"); scanf("%s",&rekaman.nama); printf("input nilai:\n"); scanf("%s",&rekaman.nilai); fprintf(arsipmatkul,"%s %s %s\n",rekaman.nim, rekaman.nama, rekaman.nilai); /* iterasi */ printf("input nim:\n"); scanf("%s", &rekaman.nim); } fprintf(arsipmatkul, "%s %s %s\n", "XXXXXX", "XXXX", "x"); fclose(arsipmatkul); return 0; }
1 Odpowiedź
0
I don't analyze the program's logic, but if you return "0", then the " main" function needs to return the "int" type:
int main() {
...
return 0;
}