如图所示,我用的是VS2005,在调试一个程序的时候,老是出现这个提示,不能启动调试,但是其它的程序是正常的,怎么回事啊?
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- char *GetMemory2(void)
- {
- char p[]="hello world";
- return p;
- }
- void Test2(void)
- {
- char *str=NULL;
- str=GetMemory2();
- printf("%s\n",str);
- }
- void GetMemory3(char **p,int num)
- {
- *p=(char*)malloc(num);
- }
- void Test3(void)
- {
- char *str=NULL;
- GetMemory3(&str,100);
- strcpy(str,"hello");
- printf("%s\n",str);
- }
- void Test4(void)
- {
- char *str=(char*)malloc(100);
- strcpy(str,"hello");
- free(str);
- if(str!=NULL)
- {
- strcpy(str,"world");
- printf("%s\n",str);
- }
-
- }
- void GetMemory(char *p)
- {
- p=(char*)malloc(100);
- }
- void Test(void)
- {
- char *str=NULL;
- GetMemory(str);
- strcpy(str,"hello,world");
- printf("%s",str);
- }
- int Func(char str[100])
- {
- return sizeof(str);
- }
- int main()
- {
- /*bool b=0;
- char *p=NULL;
- char str[]="hello";
- p=str;
- int n=10;
- void *z=malloc(100);*/
- //Test(); //会崩溃
- /*char a[3];
- strcpy(a,"hello");
- printf("%s\n",a);
- printf("\n");*/
- Test2();
- printf("---\n");
- Test3();
- printf("---\n");
- Test4();
- /*char test[3]="eh";
- strcpy(test,"hello,world");*/
- //printf("%s\n",test);
- /*printf("\n\n");
- printf("%d\n",sizeof(z));
- printf("%d,%d,%d,%d\n",sizeof(str),sizeof(p),sizeof(n),sizeof(*p));
- if(p!=NULL)
- printf("not null\n");
- else
- printf("null\n");
- if(!b)
- printf("zero\n");
- else
- printf("not zero\n");
- printf("%d",b);*/
- printf("\n");
- return 0;
- }
复制代码 |