注册 登录
编程论坛 C++教室

求助!这段代码有什么问题吗?为什么运行之后只显示黑屏?救救孩子!

佛偈水 发布于 2020-10-07 10:37, 1402 次点击
#include<stdio.h>#include<stdlib.h>#include<string.h>typedef struct student{    int score;    struct student*next;}L;    L*create(int date){    L*p=(L*)malloc(sizeof(L));    if(p=NULL)    {        printf("malloc fair!");        return NULL;    }    memset(p,0,sizeof(L));    p->score=date;    p->next=NULL;}    void tailinsert( L *ph,L *c){    L*p=ph;    while(p->next!=NULL)    {    p->next=p;    }    p->next=c;}    void print(L*ph)    {       L*p=ph;       p=p->next;       while(p!=NULL)       {           printf("%d\n",&p->score);           p=p->next;       }       printf("%d\n",&p->score);    } void detect(L*ph,int date){     L*pr=ph;     L*p=ph->next;     if(p=NULL)     {          printf("数据为空,无法删除\n");          memset(p,0,sizeof(L));     }else       while(1)       {            pr=p;            p=p->next;            if(p=NULL)            {                  printf("找不到数据\n");                   return;            }            else                   pr->next=p->next;                   free(p);       }}int main(){        L*m=create(0);        L*infor;        while(1)        {            printf("请输入您想要的数据\n");            infor = (L*)malloc(sizeof(L));            infor->next = NULL;            scanf("%d\n",&infor->score);            tailinsert(m,infor);            printf("要继续吗?\n1.yes\t2.no");            int i=getchar();            if(i==2)            {               break;            }        print(m);}        printf("请输入要删除的数据\n");        scanf("%d\n",&infor->score);        detect(m,infor->score);        return 0;}

就是这段代码,打出来之后点击运行,运行出来的程序只显示黑屏,我用的VC++6. 0
大佬们帮帮忙吧!
2 回复
#2
LG隐2020-10-08 15:33
你这格式,,
#3
纯蓝之刃2020-10-09 08:12
if(p==NULL)
1