#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LEN sizeof(struct Student)
struct Student{
char name[10];
int number;
struct Student *next;
};
struct Student * InitList();
void CreatList(struct Student *head);
void PrintList(struct Student *head);
struct Student GetListElm(struct Student *head,int i);
int main(void){
struct Student *head,student;
head=InitList();
CreatList(head);
PrintList(head);
student=GetListElm(head,2);
printf("%s",student.name);
return 0;
}
struct Student *InitList() {
struct Student *head=NULL;
head=(struct Student*)malloc(LEN);
head->next=NULL;
return head;
}
void CreatList(struct Student *head) {
struct Student *pre=NULL,*cur=NULL;
int number,n=0;
char name[10];
pre=head;
while (1){
printf("请输入学号(-1结束输入):\n");
scanf("%d",&number);
if (number==-1){
break;
}
getchar();
printf("请输入姓名:");
gets(name);
cur=(struct Student*)malloc(LEN);
cur->number=number;
strcpy(cur->name,name);
pre->next=cur;
pre=cur;
n++;
}
head->number=n;
cur->next=NULL;
}
void PrintList(struct Student *head) {
struct Student *cur=head->next;
printf("共有%d条数据\n",head->number);
while (cur!=NULL){
printf("姓名:%s\t",cur->name);
printf("学号:%d\n",cur->number);
cur=cur->next;
}
}
struct Student GetListElm(struct Student *head, int i) {
struct Student *cur=head->next;
int length=head->number,j;
if (i>length){
printf("您所查找的编号超出了链表范围");
system("pause");
exit(0);
}
for(j=0;j<i;j++){
cur=cur->next;
}
return *cur;
}
下面是软件的提示,我在百度上寻找不到答案,谢谢大佬们
Error during pretty printers setup: Undefined info command: "pretty-printer". Try "help info".
Some features and performance optimizations will not be available.
D:\practice\ManageSystem\cmake-build-debug\ManageSystem.exe
可以看看项目设置或全局设置里关于pretty-printer的, 设置输出窗口为`控制台`,貌似clion的输出捕抓失败。
Error during pretty printers setup: Undefined info command: "pretty-printer". Try "help info".
Some features and performance optimizations will not be available.
D:\practice\ManageSystem\cmake-build-debug\ManageSystem.exe
����4������
����:�� ѧ��:1
����:�� ѧ��:2
����:�� ѧ��:3
����:�� ѧ��:4
����5������
����:�� ѧ��:1
����:�� ѧ��:2
����:�� ѧ��:3
����:�� ѧ��:4
����:�� ѧ��:6
����5������
����:� ѧ��:0
����:�� ѧ��:2
����:�� ѧ��:3
����:�� ѧ��:4
����:�� ѧ��:6
����5������
����:� ѧ��:0
����:�� ѧ��:2
����:�� ѧ��:7
����:�� ѧ��:4
����:�� ѧ��:6
��:2
进程已结束,退出代码为 0
最新发现,debug是可以输出的,但必须在整个程序运行完,控制台才有输出