教教小弟我这个初学者,用eclipse写的C程序win 7下一运行就死了…
求助各位高手教教我这个菜鸟,用eclipse写的C程序win 7下一运行就死了……
源代码在这 另外我如果在函数参数里面这样写Status InitList_Sq(Sqlist &L)就会出错
expected '=', ',', ';', 'asm' or '__attribute__' before 唉 搞了半天了都没好……
------解决方案--------------------
debug下运行 看挂在哪了
是不是有死循环的情况
- C/C++ code
#include <stdio.h> #include <malloc.h> #define STUDENT Elemtype #define LIST_INIT_SIZE 100 #define LISTICREMENT 10 #define OVERFLOW -2 #define OK 1 #define ERROR 0 typedef int Status; typedef struct{ char name; int age; int chass; }STUDENT; typedef struct{ Elemtype *elem; int length; int listsize; }Sqlist; Status InitList_Sq(Sqlist *L){ (*L).elem=(Elemtype *)malloc(LIST_INIT_SIZE*sizeof(Elemtype)); if(!(*L).elem) exit(OVERFLOW); L->length=0; L->listsize=LIST_INIT_SIZE; return OK; } Status ListInsert_Sq(Sqlist *L,int i,Elemtype e){ if(i<1||i>L->length+1) return ERROR; if(L->length>=L->listsize) { Elemtype *newbase; newbase=(Elemtype *)realloc(L->elem,(L->listsize+LISTICREMENT)*sizeof(Elemtype)); if(!newbase) exit(OVERFLOW); L->elem=newbase; L->listsize+=LISTICREMENT; } Elemtype *p,*q; p=L->elem+i-1; for(q=L->elem+L->length;q>=p;q--){ *(q+1)=*q; } p=&e; L->length++; return OK; } Status GetElem(Sqlist *L,int i,Elemtype *e){ if(i<1||i>L->length) return ERROR; e=L->elem+i-1; return OK; } int main(){ Sqlist *L=NULL; Elemtype student; Elemtype *stu1=NULL; int status1,status2; student.name='a'; student.chass=1; student.age=20; InitList_Sq(L); status1=ListInsert_Sq(L,1,student); status2=GetElem(L,1,stu1); printf("%d/n",L->length); return 0; }
源代码在这 另外我如果在函数参数里面这样写Status InitList_Sq(Sqlist &L)就会出错
expected '=', ',', ';', 'asm' or '__attribute__' before 唉 搞了半天了都没好……
------解决方案--------------------
debug下运行 看挂在哪了
是不是有死循环的情况