查看: 1782|回复: 0
收起左侧

[已解决] 为什么老是提示调试信息不匹配呢?

 关闭 [复制链接]
happytor
头像被屏蔽
发表于 2008-11-6 13:34:55 | 显示全部楼层 |阅读模式
                                                                                             如图所示,我用的是VS2005,在调试一个程序的时候,老是出现这个提示,不能启动调试,但是其它的程序是正常的,怎么回事啊?

  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. char *GetMemory2(void)
  5. {
  6.         char p[]="hello world";
  7.         return p;
  8. }
  9. void Test2(void)
  10. {
  11.         char *str=NULL;
  12.         str=GetMemory2();
  13.         printf("%s\n",str);
  14. }
  15. void GetMemory3(char **p,int num)
  16. {
  17.         *p=(char*)malloc(num);
  18. }
  19. void Test3(void)
  20. {
  21.         char *str=NULL;
  22.         GetMemory3(&str,100);
  23.         strcpy(str,"hello");
  24.         printf("%s\n",str);
  25. }
  26. void Test4(void)
  27. {
  28.         char *str=(char*)malloc(100);
  29.         strcpy(str,"hello");
  30.         free(str);
  31.         if(str!=NULL)
  32.         {
  33.                 strcpy(str,"world");
  34.                 printf("%s\n",str);
  35.         }
  36.       
  37. }
  38. void GetMemory(char *p)
  39. {
  40.         p=(char*)malloc(100);
  41. }
  42. void Test(void)
  43. {
  44.         char *str=NULL;
  45.         GetMemory(str);
  46.         strcpy(str,"hello,world");
  47.         printf("%s",str);
  48. }
  49. int  Func(char str[100])
  50. {
  51.         return sizeof(str);
  52. }
  53. int main()
  54. {
  55.         /*bool b=0;
  56.         char *p=NULL;
  57.         char str[]="hello";
  58.         p=str;
  59.         int n=10;
  60.         void *z=malloc(100);*/
  61.         //Test(); //会崩溃
  62.         /*char a[3];
  63.         strcpy(a,"hello");
  64.         printf("%s\n",a);
  65.         printf("\n");*/
  66.         Test2();
  67.         printf("---\n");
  68.         Test3();
  69.         printf("---\n");
  70.         Test4();
  71.         /*char test[3]="eh";
  72.         strcpy(test,"hello,world");*/
  73.         //printf("%s\n",test);
  74.         /*printf("\n\n");
  75.         printf("%d\n",sizeof(z));
  76.         printf("%d,%d,%d,%d\n",sizeof(str),sizeof(p),sizeof(n),sizeof(*p));
  77.         if(p!=NULL)
  78.                 printf("not null\n");
  79.         else
  80.                 printf("null\n");
  81.         if(!b)
  82.                 printf("zero\n");
  83.         else
  84.                 printf("not zero\n");
  85.         printf("%d",b);*/
  86.         printf("\n");
  87.         return 0;
  88. }

复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?快速注册

x
您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

手机版|杀毒软件|软件论坛| 卡饭论坛

Copyright © KaFan  KaFan.cn All Rights Reserved.

Powered by Discuz! X3.4( 沪ICP备2020031077号-2 ) GMT+8, 2025-10-8 17:58 , Processed in 0.145872 second(s), 17 queries .

卡饭网所发布的一切软件、样本、工具、文章等仅限用于学习和研究,不得将上述内容用于商业或者其他非法用途,否则产生的一切后果自负,本站信息来自网络,版权争议问题与本站无关,您必须在下载后的24小时之内从您的电脑中彻底删除上述信息,如有问题请通过邮件与我们联系。

快速回复 客服 返回顶部 返回列表