有人可以帮忙吗? [英] Can Someone please help?
问题描述
我是新的C程序学生。
我想我们是否可以在C中编写一个只触发其功能来执行某项操作的程序?
在这种情况下,我有一个程序,但它不工作。
我想要的是打印Hello的功能。没有向函数传递值。
编写程序的正确方法是什么?
#include< stdio.h>
无效计算; / *函数原型* /
int main()
{计算; / *函数调用* /
返回0;
}
无效计算
{
printf(你好);
返回;
}
谢谢
Tim
----- BEGIN PGP签名消息-----
哈希:SHA1
Tiny Tim写道:
我是新的C程序学生。
我想知道我们能不能在C中编写一个程序只是触发它的功能才能执行某个操作?
在这种情况下,我有一个程序但它不起作用。
我想要的是用于打印Hello的功能。没有向函数传递值。
编写程序的正确方法是什么?
#include< stdio.h>
无效计算; / *函数原型* /
Nope。
这不是函数原型。
然而,
无效计算(无效);
是函数原型。
注意区别?一个函数(原型与否)有一个零/
或更多参数的列表,并通过
跟踪括号参数列表指定为函数。 />
int main()
{计算; / *函数调用* /
不。那不是函数调用。充其量(Compute没有被声明为无效的
),这将是一个涉及单个
变量的表达式。
如果你想要一个函数调用,你应该编码
Compute();
return 0;
}
void计算
需要零个或多个参数的参数列表
应该是
void Compute()/ *或者void void Compute(void)* /
{
printf(" Hello");
返回;
}
谢谢
Tim
HTH
- -
Lew Pitcher
-----开始PGP签名-----
版本:GnuPG v1.4.3(MingW32) - WinPT 0.11.12
iD8DBQFE4zjNagVFX4UWr64RAuR2AJ9YfRph / ZbwBG8nH7qOziTqddV8JQCfXMte
n20INoD8 + uggOY5YzXzwdWA =
= + C8Q
-----结束PGP签名-----
Tiny Tim< ; ts ***** @ streamyx.comwrote:
[ - text / plain,encoding quoted-printable,charset:iso-8859-1,25行 - ]
如果可以提供帮助,请不要发表编码文章。
#include< stdio.h>
void Compute; / *函数原型* /
void Compute(); / *注意括号* /
int main()
{
计算; / *函数调用* /
Compute(); / *再次* /
返回0;
}
void计算
void Compute()/ *再次* /
{
printf(" Hello" );
返回;
}
我建议购买一本C书,最好是 C编程
语言,尽快。
-
C. Benson Manica |我*应该*知道我在说什么 - 如果我
cbmanica(at)gmail.com |不,我需要知道。火焰欢迎。
>
Nope。那不是函数调用。充其量(Compute没有被声明为无效的
),这将是一个涉及单个
变量的表达式。
如果你想要一个函数调用,你应该编码
计算();
- -
Lew Pitcher
谢谢Lew Pitcher先生
这样的超级回复。
我遇到了问题已经解决了。
现在我可以继续前进了。
再次感谢
Rgds,
Tim
I am new C program student.
I wonder can we write a program in C that just trigger its function to do a certain action ?
In this case, I have a program but it is not working.
What I want is for the function to print "Hello". No passing of values to or from the function.
What is the correct way to write the program?
#include <stdio.h>
void Compute ; /*function prototype*/
int main ()
{ Compute; /*function call*/
return 0 ;
}
void Compute
{
printf ("Hello");
return ;
}
Thank you
Tim
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Tiny Tim wrote:I am new C program student.
I wonder can we write a program in C that just trigger its function to do a certain action ?
In this case, I have a program but it is not working.
What I want is for the function to print "Hello". No passing of values to or from the function.
What is the correct way to write the program?
#include <stdio.h>
void Compute ; /*function prototype*/Nope.
That''s not a function prototype.
However,
void Compute(void);
is a function prototype.
Notice the difference? A function (prototype or not) has a list of zero
or more parameters, and is designated as a function by the presence of
the trailing bracketed parameter list.
int main ()
{ Compute; /*function call*/Nope. That''s not a function call. At best (had Compute not been
declared as void), that would be an expression involving a single
variable.
If you wanted a function call, you should have coded
Compute();
return 0 ;
}
void ComputeRequires a parameter list of zero or more parameters
Should have been
void Compute() /* or perhaps void Compute(void) */{
printf ("Hello");
return ;
}
Thank you
TimHTH
- --
Lew Pitcher
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32) - WinPT 0.11.12
iD8DBQFE4zjNagVFX4UWr64RAuR2AJ9YfRph/ZbwBG8nH7qOziTqddV8JQCfXMte
n20INoD8+uggOY5YzXzwdWA=
=+C8Q
-----END PGP SIGNATURE-----
Tiny Tim <ts*****@streamyx.comwrote:
[-- text/plain, encoding quoted-printable, charset: iso-8859-1, 25 lines --]Please don''t post encoded articles, if you can help it.
#include <stdio.h>
void Compute ; /*function prototype*/void Compute(); /* note parentheses */
int main ()
{
Compute; /*function call*/Compute(); /* again */
return 0 ;
}
void Computevoid Compute() /* and again */
{
printf ("Hello");
return ;
}I''d advise procuring a C book, preferably "The C Programming
Language", as soon as possible.
--
C. Benson Manica | I *should* know what I''m talking about - if I
cbmanica(at)gmail.com | don''t, I need to know. Flames welcome.
>Nope. That''s not a function call. At best (had Compute not been
declared as void), that would be an expression involving a single
variable.
If you wanted a function call, you should have coded
Compute();
- --
Lew PitcherThank you Mr. Lew Pitcher
for such a superspeed reply.
I got my problem solved already.
Now I can move on.
Thanks again
Rgds,
Tim
这篇关于有人可以帮忙吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!