为什么用devc++编译下面的代码,运行会提示内存不可写?#in
2011-06-15 20:24:21坐***
#include<stdio.h>
#include<string.h>
int main()
{
char *pch,ch;
int n1,n2;
printf("The first number:");
scanf("%s",pch);
n1=strlen(pch);
printf("The second number:");
scanf("%s",pch);
n2=strlen(pch);
printf("%d %d",n1,n2);
}为什么用devc++编译下面的代码,运行会提示内存不可写?#includestdio.h#includestring.hintm?
最佳回答
2011-06-15 22:23:19
2011-06-19 09:14:56
2011-06-18 12:44:41
错误出在: 指针调用之前没有赋值。使用指针千万要注意这点。 因为没有赋值的指针所指向的空间不确定。你将内容写入不确定的地址肯定出错。 顺便说句C++里的String。C里面还是别用。有点怪怪的。 楼主加油了。
2011-06-15 22:02:49
很赞哦! (254)
相关文章
- 关于devc++的问题在使用de
- 推荐能在WindowsXP系统下
- 如何给DEV-C编译完成的exe
- 习惯了eclipse用DEVC同
- MicrosoftVisualS
- DevC++怎么改gcc?环境变
- 用哪个C/C++编译器能够绘出图
- C语言指针voidfun(int
- devc中编辑一个程序后怎么不能
- c语言警告处理1.想将-1赋值给
- 从文件流读取char到vecto
- clodeblocks的envi
- 如何给DEV-C++编译完成的e
- 用Devc++查找函数
- 编写一个函数,用于生成一个空字符
- C++指针常量的问题intmai
- 在visualstudio200
- 应用程序错误是怎么回事?我从网上
- devC如下报错是什么问题?[E
- 什么叫写保护?我的内存卡老是会有
- 正在运行的程序任务栏不显示怎么修