一个C语言的题

来源:百度知道 编辑:UC知道 时间:2024/05/23 11:03:09
#include <stdio.h>

void main ()
{
int result;

result = printf("Jamsa's 1001 C & C++ Tips!\n");

if (result == EOF)
fprintf(stderr, "Error within printf\n");
}
每句都代表什么意思

void main () ----------------主函数
{
int result; 定义一个整数型的 变量 result

result = printf("Jamsa's 1001 C & C++ Tips!\n"); ---第一次见这种付值法,若你的这行正确的话,result的值应该是1。应该是 在一个文件中读取数据。你把读取函数是不是写错了

if (result == EOF) 判断 result是不是等于“eof(有其特定的意义--结尾)”
fprintf(stderr, "Error within printf\n"); 把“Error within printf”输出到文件 stderr中,
}
每句都代表什么意思

请楼上不要误人子弟
回答者:nulinuli - 试用期 一级 11-10 23:48

呵呵,我已经4年没有接触过C语言了,而且是个大夫,对于你给我这样的提示,我绝对该反省反省。

楼主,不看我的答案也罢。不过你 这题却是不是很难,拿出C语言书回到相关章节 看看各个函数的作用即格式就一目了然了。

请楼上不要误人子弟

是一个类似 JAVA里异常处理的程序,用RESULT的返回值判断是不是那条输出语句运行情况,若没有正常输出则利用下面的语句 报错..
就这样

我把tc20对于printf函数的帮助文件写给你看:

printf:formatted output to stdout
int printf(const char *format,...);
Prototype in stdio.h

Print formats a variable number of arguments
according to the format,and sends the output
to stdout.Returns the number of bytes