C语言中这些符号的作用?

#include<stdio.h>
int main(void)
{
long a;
int b,c;
long sum1,sum2;
a=65534;
b=1;
c=2;
sum1=a+b;
sum2=a+c;
printf("%ld\n",sum1);
printf("%ld\n",sum2);
getch();
return 0;
}
这里的%ld\n 是什么意思?
同样的在别的地方还有 %u\n等等
类似的有多少符号,都在什么地方用?
getch() 是什么意思?有什么用?
return 0 有什么用?

请各位大牛赐教。
O(∩_∩)O谢谢

这里的%ld\n 是什么意思?
是 输出 长整形 十进制 数
同样的在别的地方还有 %u\n等等
输出 无符号的 十进制数

类似的有多少符号,都在什么地方用?
格式化字符串的例子,在C语言的参考里有
c Character a
d or i Signed decimal integer 392
e Scientific notation (mantise/exponent) using e character 3.9265e+2
E Scientific notation (mantise/exponent) using E character 3.9265E+2
f Decimal floating point 392.65
g Use the shorter of %e or %f 392.65
G Use the shorter of %E or %f 392.65
o Signed octal 610
s String of characters sample
u Unsigned decimal integer 7235
x Unsigned hexadecimal integer 7fa
X Unsigned hexadecimal integer (capital letters) 7FA
p Pointer address B800:0000
n Nothing printed. The argument must be a pointer to a signed int, where the number of characters written so far is stored.
% A % followed by another % character will write % to stdout.

在printf函数中使用,表示格式化输出
getch() 是什么意思?有什么用?
这个不标准,标准的是 getchar()就是获取一个字符输入
return 0 有什么用?
就是函数运行结束后返回一个值,这个值是0。因为有些程序是系统要用的,系统要根据返回的值做出反应。

参考资料:http://www.cplusplus.com/reference/clibrary/cstdio/printf/

温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-06-12
第一第二个里的ld和u指的是规定了输出的SUM的格式,具体定义在课本后面附表有,%n是回车,第三个是取值,不用太重视,第四个是返回值,返回0。
第2个回答  2010-06-12
%ld表示长整型,\n表示换行
%u表示将数据按照无符号整数数值输出
类似的有%f表示浮点型等,这个是c语言的基础,你看下c语言课本就知道了
getch()表示获取字符,用处就是获取前面输出的字符了
return 0是个返回值,返回0

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网