傢伙... u能幫助我在我的代碼中應用的malloc ...這裏是我的代碼:應用的malloc
#include<stdio.h>
#include<stdlib.h>
struct studentinfo{
char id[8];
char name[30];
char course[5];
}s1;
main(){
int i;
FILE *stream = NULL;
stream = fopen("studentinfo.txt", "a+");
struct studentinfo s1;
struct studentinfo array[3];
for (i =0; i<1; i++){
printf("Enter Student ID: ");
scanf("%s", s1.id);
fflush(stdin);
printf("Enter Student Name: ");
gets(s1.name);
fflush(stdin);
printf("Enter Student Course: ");
scanf("%s", s1.course);
fprintf(stream, "\n%s,\t%s,\t%s", s1.id, s1.name, s1.course);
}
fclose(stream);
getch();
}
我知道的malloc alots比一般的陣列更多的空間......但還是即時通訊有使用硬一次...非常感謝:)
至少* *試試... – 2010-12-03 13:22:47
`爲(i = 0;我<1;我++)`? – 2010-12-03 13:26:13