c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Student
{
char * id;
struct Student* next;
}stu;
stu* creatNode(char *idStr)
{
stu *newNode=(stu*)malloc(sizeof(stu));
newNode->id=(char*)malloc(sizeof(idStr));
strcpy(newNode->id,idStr);
newNode->next=NULL;
return newNode;
}
void printf1(stu* head)
{
stu* current=head->next;
while(current!=NULL)
{
printf("%s",current->id);
current=current->next;
}
}
// 主函数测试
int main() {
stu* head=(stu*)malloc(sizeof(stu));
head->next=NULL;
stu* node1=creatNode("1");
head->next=node1;
stu* node2=creatNode("2");
node1->next=node2;
stu* node3=creatNode("3");
node2->next=node3;
printf1(head);
free(head);
}