出现黑屏后为何无法输入数据阿?谢谢哦!!
#include<stdlib.h>
#include<iostream.h>
#include<stdio.h>
#include<string.h>
struct student{
char name[10];
int num;
int age;
char sex;
float score;
struct student *next;};
void appendnewdode(void);
void listall(void);
struct student * head=NULL,*thisnode,* newnode;
void appendnewnode(void) {
char numstr[20];
newnode=(struct student*)malloc(sizeof(struct student));
if(head==NULL) head=newnode;
else
{thisnode=head;
while(thisnode->next!=NULL)
thisnode=thisnode->next;
thisnode->next=newnode;}
thisnode=newnode;
cout<<"enter student name:"<<endl;
gets(thisnode->name);
cout<<"enter number"<<endl;
gets(numstr);
thisnode->num=atoi(numstr);
cout<<"enter age"<<endl;
thisnode->age=getchar();
cout<<"sex:"<<endl;
thisnode->sex=getchar();
cout<<"score:"<<endl;
gets(numstr);
thisnode->score=atof(numstr);
thisnode->next=NULL;
}
void listall(void) {
int i=0;
if(head==NULL) {cout<<"empty list";
return;}
thisnode=head;
do{
cout<<"name:"<<thisnode->name<<endl;
cout<<"num:"<<thisnode->num<<endl;
cout<<"age:"<<thisnode->age<<endl;
cout<<"score:"<<thisnode->score<<endl;
cout<<"sex:"<<thisnode->sex<<endl;
thisnode=thisnode->next;}while(thisnode!=NULL);
}
void main()
{
char ch;
int flag=1;
while(flag){
cout<<"enter e or E to append new node"<<endl;
cout<<"enter l or L to list all"<<endl;
ch=getchar();
switch(ch)
{
case 'e':case'E':appendnewnode();break;
case 'l':case 'L':listall();break;
default:flag=0;
}
}
}