C 구조 체 지침 (노농 과 교류 하 는)

#include "stdio.h"
#include <stdlib.h>  
#include <string.h>  
struct student{
       int num;
       char *name;
       struct student *next;
};

int main(void)
{
    struct student a,b,c,*head,*p;
    
    a.name = "lilia";
    b.name = "lilib";
    c.name = "lilic";
    
    a.num = 1;
    b.num = 2;
    c.num = 3;
    
    head = &a;
    a.next = &b;
    b.next = &c;
    c.next = NULL;
    
    p = head;
	printf("a.num=%d a.name=%s
",a.num,a.name); while(p!=NULL) { printf("%d %s
",p->num,p->name); p=p->next; } return 1; }
#include "stdio.h"

struct student{
       int num;
       char name;
       struct student *next;
};

int main(void)
{
    struct student a,b,c,*head,*p;

    a.name = 'a';
    b.name = 'b';
    c.name = 'c';

    a.num = 1;
    b.num = 2;
    c.num = 3;

    head = &a;
    a.next = &b;
    b.next = &c;
    c.next = NULL;

    p = head;
	while(p!=NULL)  
    {  
        printf("%d %c
",p->num,p->name); p=p->next; } /* while(p != NULL){ printf("d% s%
",p->num,p->name); p = p->next; }*/ return 1; }

   

좋은 웹페이지 즐겨찾기