| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1171 人关注过本帖
标题:请各位看看,这个简单的程序为什么运行报错呢?
只看楼主 加入收藏
lj120122
Rank: 1
等 级:新手上路
帖 子:23
专家分:8
注 册:2012-11-26
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:15 
请各位看看,这个简单的程序为什么运行报错呢?
#include<stdio.h>
void main()
{
    int a[10];
    for(int i=0;i<10;i++)
    scanf("%d",&a[i]);
    printf("\n");
    for(int j=0;j<10;j++)
    printf("%d",a[i]);
    printf("\n");
}
搜索更多相关主题的帖子: 看看 
2013-03-11 20:44
未名湖的云
Rank: 3Rank: 3
来 自:安徽
等 级:论坛游侠
帖 子:130
专家分:190
注 册:2012-10-11
收藏
得分:2 
回复 楼主 lj120122
#include<stdio.h>
void main()
{
    int a[10];
    for(int i=0;i<10;i++)
    scanf("%d",&a[i]);
    printf("\n");
    for(int j=0;j<10;j++)
    printf("%d",a[i]);//这里怎么是i?????此时i=10,数组越界
    printf("\n");
}

[ 本帖最后由 未名湖的云 于 2013-3-11 21:07 编辑 ]
2013-03-11 20:59
lj120122
Rank: 1
等 级:新手上路
帖 子:23
专家分:8
注 册:2012-11-26
收藏
得分:0 
回复 2楼 未名湖的云
不好意思,写错了,是j,请指点一下!
2013-03-11 21:03
未名湖的云
Rank: 3Rank: 3
来 自:安徽
等 级:论坛游侠
帖 子:130
专家分:190
注 册:2012-10-11
收藏
得分:0 
回复 3楼 lj120122
什么错误????
2013-03-11 21:08
lj120122
Rank: 1
等 级:新手上路
帖 子:23
专家分:8
注 册:2012-11-26
收藏
得分:0 
回复 4楼 未名湖的云
e:\download\notepad++\test.c(7) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(7) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(7) : error C2143: syntax error : missing ')' before 'type'
e:\download\notepad++\test.c(7) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(7) : error C2065: 'i' : undeclared identifier
e:\download\notepad++\test.c(7) : warning C4552: '<' : operator has no effect; expected operator with side-effect
e:\download\notepad++\test.c(7) : error C2059: syntax error : ')'
e:\download\notepad++\test.c(8) : error C2146: syntax error : missing ';' before identifier 'scanf'
e:\download\notepad++\test.c(10) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(10) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(10) : error C2143: syntax error : missing ')' before 'type'
e:\download\notepad++\test.c(10) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(10) : error C2065: 'j' : undeclared identifier
e:\download\notepad++\test.c(10) : warning C4552: '<' : operator has no effect; expected operator with side-effect
e:\download\notepad++\test.c(10) : error C2059: syntax error : ')'
e:\download\notepad++\test.c(11) : error C2146: syntax error : missing ';' before identifier 'printf'
2013-03-11 21:16
lj120122
Rank: 1
等 级:新手上路
帖 子:23
专家分:8
注 册:2012-11-26
收藏
得分:0 
回复 4楼 未名湖的云
e:\download\notepad++\test.c(7) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(7) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(7) : error C2143: syntax error : missing ')' before 'type'
e:\download\notepad++\test.c(7) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(7) : error C2065: 'i' : undeclared identifier
e:\download\notepad++\test.c(7) : warning C4552: '<' : operator has no effect; expected operator with side-effect
e:\download\notepad++\test.c(7) : error C2059: syntax error : ')'
e:\download\notepad++\test.c(8) : error C2146: syntax error : missing ';' before identifier 'scanf'
e:\download\notepad++\test.c(10) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(10) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(10) : error C2143: syntax error : missing ')' before 'type'
e:\download\notepad++\test.c(10) : error C2143: syntax error : missing ';' before 'type'
e:\download\notepad++\test.c(10) : error C2065: 'j' : undeclared identifier
e:\download\notepad++\test.c(10) : warning C4552: '<' : operator has no effect; expected operator with side-effect
e:\download\notepad++\test.c(10) : error C2059: syntax error : ')'
e:\download\notepad++\test.c(11) : error C2146: syntax error : missing ';' before identifier 'printf'
2013-03-11 21:16
梅可伟梅可伟
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:69
专家分:180
注 册:2013-3-11
收藏
得分:2 
如果是j 的话就没有错误了,完全能够运行
2013-03-11 22:05
yzz91
Rank: 2
等 级:论坛游民
帖 子:19
专家分:12
注 册:2012-11-13
收藏
得分:2 
#include<stdio.h>
void main()
{
    int a[10],i,j;
    for( i=0;i<10;i++)
    scanf("%d",&a[i]);
    printf("\n");
    for( j=0;j<10;j++)
    printf("%d",a[j]);
    printf("\n");
}
c语言for 语句中不能定义i,j。
2013-03-11 22:15
小xiong
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:388
专家分:1722
注 册:2013-2-8
收藏
得分:2 
呵呵
2013-03-11 23:51
a77232923
Rank: 1
等 级:新手上路
帖 子:11
专家分:9
注 册:2011-5-21
收藏
得分:2 
呵呵你程序中‘j’定义了没?int i,j;这样就可以了
2013-03-12 08:08
快速回复:请各位看看,这个简单的程序为什么运行报错呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012633 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved