0
我正在基於用戶輸入如下面的鏈表(S):如何在C中使用多個節點實現鏈表?
How Many employees? 4
現在,每個人將有firstname
lastname
rate
和zipcode
,用鏈表我試圖把這些輸入和這樣做基於的記錄數的for
循環,但我不這樣做是正確明顯:
struct records {
char first[20];
char last[20];
float rate;
int zip;
struct node* next;
};
void main()
{
int i,n;
printf("Please indicate the number of records : ");
scanf("%d",&n);
struct records *head,*conductor;
head=(struct records*)malloc(n*sizeof(struct records));
head->next=NULL;
for (i=0;i<n;i++){
printf("\nEnter employee information in the format :\nFirstname Lastname rate Zipcode (newline for the next)\n");
scanf("%s %s %f %d",&head->first,&head->last,&head->rate,&head->zip);
conductor=head;
conductor=conductor->next;}
}
我如何得到這個權利?