编辑代码

#include <stdio.h>
#include <stdlib.h>


#define NULL 0
#define TYPE struct stu
#define LEN sizeof (struct stu)
struct stu{
    int num;
    int age;
    struct stu *next;
};

TYPE *creat_LinkList(int n){
    struct stu *head,*pf,*pb;
    int i;
    for(i=0;i<n;i++){  
        pb=(TYPE*) malloc(LEN);
        printf("input Number and  Age\n");
        scanf("%d%d",&pb->num,&pb->age);
        if(i==0) pf=head=pb;
        else pf->next=pb;
        pb->next=NULL;
        pf=pb;
    }
    return(head);
}


int main () {
     //JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
    printf("Hello JSRUN!   \n\n         - from C .");
    struct stu *p ,*pnow;
    p = creat_LinkList(2);
    pnow = p;
    for(int i=0 ; i<2 ; i++)
    {
        printf("num: %d, age: %d, p: %p, p->next: %p\n",pnow->num, pnow->age,pnow,pnow->next);
        pnow=pnow->next;
    } 
    return 0;
}