-2
나는이 구조체가 정의되어 내 주요 기능에C 프로그래밍 호출 포인터의 포인터
typedef struct {
char *first_name;
char *last_name;
char SSN[9];
float gpa;
struct student *next;
} student;
typedef struct {
student *head;
student *current;
student *tail;
} students;
, 나는 학생들 구조체에 학생을 추가 할 수 있습니다. 그리고 head student의 first_name을 호출하십시오. 어떻게해야합니까?
void add(students *list, student *a) {
if(list->head) {
a->next = NULL;
list->head = &a;
list->current = list->head;
list->tail = NULL;
} else {
printf("Will implement");
}
}
int main()
{
students grade1;
student a;
a.first_name = &"Misc";
a.last_name = &"Help";
add(&grade1, &a);
printf("%s %s", a.first_name, a.last_name);
printf("%s", grade1.head->first_name);
}
printf ("% s", grade1.head-> first_name);
작동하지 않는 것 같습니다. 어떤 제안?
감사
모든
'작동하지 않는 것 같습니다.'작동하지 않는 것은 무엇입니까? 뭘 원해? 이 코드가 컴파일됩니까? 문제에 대해 구체적으로 설명하십시오. –
'list-> head = & a;'행에 잘못된 유형에 대한 경고가 표시되지 않습니까? 새로운 학생이 목록의 머리에 놓여지면 목록의 오래된 머리에 무엇인가 놓을 필요가 없으므로 잃지 않도록하십시오. – Barmar
나는 grade1.head-> first_name을 반환하기를 원한다. – Raza