回复 2楼 rjsp
这是我的代码,我想做一个类似链表的东西,能随时添加新的“教师”,我自认为我的代码可以实现这个功能,但是不可以,请您帮我看看

程序代码:
#include <iostream>
#include<conio.h>
#include<string.h>
using namespace std;
struct teacher
{
char name[10], title[7];
teacher *next;
};
teacher find(teacher head)
{
if (head.next == NULL)
return head;
else
find(*(head.next));
}
int main()
{
teacher head ;
head.next = NULL;
strcpy_s(head.name, "spname");
strcpy_s(head.title, "stitle");
while (true)
{
cout << "是否要添加教师?(y/n)";
char c;
char name[10], title[7];
c = _getch();
if (c == 'y' || c == 'Y')
{
teacher* tem;
find(head).next = tem;
cout << "教师的姓名是?\n";
cin >> name;
cout << "教师的职称是?\n";
cin >> title;
strcpy_s(find(head).next->name, name); strcpy_s(find(head).next->title, title);
find(head).next->next = NULL;
cout << "添加成功!";
}
else break;
}
}