|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 zhoutong 于 2011-12-18 20:41 编辑
1>------ 已启动生成: 项目: 用指针将数组的N个数反序输出, 配置: Debug Win32 ------
1>生成启动时间为 2011/12/18 20:09:23。
1>InitializeBuildStatus:
1> 正在创建“Debug\用指针将数组的N个数反序输出.unsuccessfulbuild”,因为已指定“AlwaysCreate”。
1>ClCompile:
1> fanxushuchu.cpp
1>e:\我的文档\visual studio 2010\projects\用指针将数组的n个数反序输出\用指针将数组的n个数反序输出\fanxushuchu.cpp(8): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\program files\microsoft visual studio 10.0\vc\include\stdio.h(304) : 参见“scanf”的声明
1>e:\我的文档\visual studio 2010\projects\用指针将数组的n个数反序输出\用指针将数组的n个数反序输出\fanxushuchu.cpp(9): error C2664: “inv”: 不能将参数 1 从“int”转换为“int []”
1> 从整型转换为指针类型要求 reinterpret_cast、C 样式转换或函数样式转换
1>
1>生成失败。
1>
1>已用时间 00:00:00.24
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
#include <stdio.h>
void inv( int a1[10] , int a2 ) ;
int main( int argc , char * argv [ ] )
{
int a[10] , b ;
printf ( "输入十个整数:" ) ;
for ( b = 0 ; b < 10 ; b ++ )
scanf ( "%d" , &a ) ;
inv( a[10] , 10 ) ;
for ( b = 0 ; b < 10 ; b ++ )
printf ( "%d " , a ) ;
printf ( "\n" ) ;
return 0 ;
}
void inv( int a1[10] , int a2 )
{
int temp , c ;
for ( c = 0 ; c <= ( a2-1 ) / 2 ; c ++ )
{
a2 = a2 - 1 ;
temp = a1[c] ;
a1[c] = a1[a2] ;
a1[a2] = temp ;
}
}
这里的 (inv( a[10] , 10 ))a[10] 为什么是错的?
用什么函数可以统计数组元素个数?
|
|