今天做题,再次碰到了指针的问题,用了不同的编译器,会有不同的反映。在C-Free下处理没有问题了,提交后出现了 ACCESS_VIOLATION 的问题,于是又换了Code::Blocks 出现了问题,但是不懂如何debug,还请大神帮忙分析下。。。。。
题目链接:http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=2&problemid=23
Problem Description
Since all we know the ASCII code, your job is simple: input numbers and output corresponding messages.
|
Input
The first line contains one integer T (1<=T<=1000).
The input will contain T positive integers separated by whitespaces (spaces, newlines, TABs). The integers will be no less than 32. |
Output
Output the corresponding message in just one line.
Warning: no extra characters are allowed. |
Sample Input
13 72 101 108 108 111 44 32 119 111 114 108 100 33 |
Sample Output
Hello, world! |
代码区:
我的问题代码:
#include"stdio.h" #include"string.h" int main(){ char a[1000],*b; int i,j,k; scanf("%d",&i); //程序代码出错段 start for(j=0;j<i;j++){ scanf("%d",b); strcat(a,b); } //end printf("%s",a); }
没有使用指针的正确代码:
#include"stdio.h" int main(){ int a[1000]; int i,j; scanf("%d",&i); for(j=0;j<i;j++){ scanf("%d",&a[j]); } for(j=0;j<i;j++){ printf("%c",a[j]); } }
我的猜想:可能是scanf函数中在获取char型数据时在类型转换上的内存问题
相关推荐
Playframework 1.2.7 sdk zip包
axiom-api-1.2.7.jar为的是更好的发扬优良的精要的代码!
zlib-devel-1.2.7-17.el7
struts源码 struts struts1.2.7
jtds-1.2.7 可以在androidAPP程序开发中使用,测试通过,有需要下载的同学可以试试,为了50个字也是拼了
zlib-1.2.7官网上的
struts-1.2.7.rar,struts-1.2.7.rar,struts-1.2.7.rar
fastjson1.2.7 依赖JDk1.8
log4j1.2.7版本,标准。
zlib-1.2.7-18.el7.x86_64.rpm
libz.so.1.2.7
zlib 1.2.7 上次传的不知道怎么没了,重新传了个,有需要的同学自己拿了 rydiy友情分享 编译可见http://blog.csdn.net/rydiy/article/details/7710294
里面包含有一些比较老版本的依赖,这些rpm包很不好找,费了好大劲才找到,给有需要的人,里面包含有openssl-1.1.1b.tar、openssl-devel-1.0.2k-16.el7.x86_64.rpm、zlib-1.2.7-18.el7.x86_64.rpm、zlib-devel-1.2.7-...
apr-1.2.7.tar.gz
android studio 或者 Eclipse 均可以通过 jtds-1.2.7.jar 直接连接sqlserver数据库,非常好用。
keepalived-1.2.7 linux mysql
AirtestIDE-win-1.2.7
大牛助手1.2.7
foobar的sacd1.2.7版,截至21.2月官方最新版