c语言小程序 帮我看看哪里错了

#include <stdio.h>
void try(int,int,int);
main()
{
int x=2,y=3,z=0;
pirntf("%d%d%d",x,y,z);
try(x,y,z);
pirntf("%d%d%d",x,y,z);
}
void try(int x,int y,int z);
{
pirntf("%d%d%d",x,y,z);
z=x+y;
x=x*x;
y=y*y;
pirntf("%d%d%d",x,y,z);
}

--------------------Configuration: 函数如何传递 - Win32 Debug--------------------
Compiling...
函数如何传递.cpp
G:\c语言的暑假\3\函数如何传递.cpp(2) : warning C4091: '' : ignored on left of 'void' when no variable is declared
G:\c语言的暑假\3\函数如何传递.cpp(2) : error C2143: syntax error : missing ';' before 'try'
G:\c语言的暑假\3\函数如何传递.cpp(2) : error C2143: syntax error : missing ';' before 'try'
G:\c语言的暑假\3\函数如何传递.cpp(6) : error C2065: 'pirntf' : undeclared identifier
G:\c语言的暑假\3\函数如何传递.cpp(7) : error C2319: 'try' must be followed by a compound statement. Missing '{'
G:\c语言的暑假\3\函数如何传递.cpp(8) : error C2317: 'try' block starting on line '7' has no catch handlers
G:\c语言的暑假\3\函数如何传递.cpp(9) : warning C4508: 'main' : function should return a value; 'void' return type assumed
G:\c语言的暑假\3\函数如何传递.cpp(10) : warning C4091: '' : ignored on left of 'void' when no variable is declared
G:\c语言的暑假\3\函数如何传递.cpp(10) : error C2143: syntax error : missing ';' before 'try'
G:\c语言的暑假\3\函数如何传递.cpp(10) : error C2143: syntax error : missing ';' before 'try'
G:\c语言的暑假\3\函数如何传递.cpp(11) : error C2447: missing function header (old-style formal list?)
执行 cl.exe 时出错.

函数如何传递.obj - 1 error(s), 0 warning(s)

小弟很菜鸟 见谅 勿喷

pirntf("%d%d%d",x,y,z); 应该改为printf,对应G:\c语言的暑假\3\函数如何传递.cpp(6) : error C2065: 'pirntf' : undeclared identifier
函数定义语句void try(int x,int y,int z);
去掉后面的;

.try是c++中已有的函数,可以换一个名称尽量不要与编译系统的关键字重复……
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-07-14
果然是……
不知道怎么说你了

是printf啊,不是pirntf
还有多加了分号,还有输出格式很不好

#include <stdio.h>
void try(int,int,int);
main()
{
int x=2,y=3,z=0;
printf("%d %d %d\n",x,y,z);
try(x,y,z);
printf("%d %d %d\n",x,y,z);
}
void try(int x,int y,int z) //此处多加了分号
{
printf("%d %d %d\n",x,y,z);
z=x+y;
x=x*x;
y=y*y;
printf("%d %d %d\n",x,y,z);
}
第2个回答  2011-07-14
1.printf打成pirntf
2.try是c++中已有的函数,换别的名字吧
3.try函数的实现后面多了一个分号
第3个回答  2011-07-15
函数的编写相当于一个小模块,最后不能有分号
第4个回答  推荐于2016-07-20
#include <stdio.h>
void ary(int,int,int); //把try换成ary
main()
{
int x=2,y=3,z=0;
printf("%d %d %d\n",x,y,z); //把pirntf换成printf
ary(x,y,z);
printf("%d %d %d\n",x,y,z);
}
void ary(int x,int y,int z) //此处多了分号
{
printf("%d %d %d\n",x,y,z);
z=x+y;
x=x*x;
y=y*y;
printf("%d %d %d\n",x,y,z);
}本回答被提问者采纳
相似回答