标签:null using char before end strcmp namespace string student
#include <iostream>
#include <string.h>
using namespace std;
struct student{
int age;
char name[10];
char sex[5];
student *next;
};
//链表的增删查改---增;
int main(){
cout<<"请输入学生信息:"<<endl;
student c={39,"xiaobai","boy",NULL};
student b={29,"xiaohong","girl",&c};
student a={10,"xiaoming","boy",&b};
student d={18,"keke","boy",NULL};
student *head=&a;
student *before=head;
student *pointer=before->next;
while(before){
if(strcmp(before->name,"xiaohong")==0)
{
d.next=pointer;
before->next=&d;
break;
}
else
before=pointer;
pointer=pointer->next;
}
before=head;
while(before){
cout<<before->age<<"-"<<before->name<<"-"<<before->sex<<endl;
before=before->next;
}
return 0;
}
标签:null using char before end strcmp namespace string student
原文地址:https://www.cnblogs.com/Mr-Zhao---haolong/p/12915946.html