Z
Zhang Yuan
----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
struct stu{
int num;
char name[12];
int age[0];
struct stu *next;
};
int main(){
struct stu *curr,*head;
head=(stu *)malloc(sizeof(stu));
curr=head;
scanf("%d",&(head->num));
curr->next=NULL;
while(curr->num!=0){
scanf("%s%d",curr->name,curr->age);
curr=(stu *)malloc(sizeof(struct stu));
scanf("%d",&(curr->num));
curr->next=NULL;
}
return 0;
}
--------------------------------------------------------------------------
it doesn't work.When I debug:
input :
101 zhang 19
the memory information:4 pictures
http://flic.kr/p/ccMQey
why 0x6f17e0 change from 00-->13 unexpectedly.
I think the "*next" and "int age"storaged in different place.
but it looks like it overwrite?
#include<stdio.h>
#include<stdlib.h>
struct stu{
int num;
char name[12];
int age[0];
struct stu *next;
};
int main(){
struct stu *curr,*head;
head=(stu *)malloc(sizeof(stu));
curr=head;
scanf("%d",&(head->num));
curr->next=NULL;
while(curr->num!=0){
scanf("%s%d",curr->name,curr->age);
curr=(stu *)malloc(sizeof(struct stu));
scanf("%d",&(curr->num));
curr->next=NULL;
}
return 0;
}
--------------------------------------------------------------------------
it doesn't work.When I debug:
input :
101 zhang 19
the memory information:4 pictures
http://flic.kr/p/ccMQey
why 0x6f17e0 change from 00-->13 unexpectedly.
I think the "*next" and "int age"storaged in different place.
but it looks like it overwrite?