C复习笔记(2)-6.18
来源:互联网 发布:.9.png制作工具 mac版 编辑:程序博客网 时间:2024/05/21 06:49
6月18日
#include <stdio.h>
(1)
/*count characters in input; 1st version*/
int main(void)
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld/n",nc);
return 0;
}
Note: when you Enter Backspace key, the machine would send the buffered string into input,
So 12345 counts 6.
(2)
#include <stdio.h>
/*count lines in input;*/
int main(void)
{
int c,nl;
nl = 0;
while ((c = getchar())!= EOF)
if (c == '/n')
++nl;
printf("%ld",nl);
}
Newcomers to C occasionally write = when they mean ==. The result is usually a legal expression, so you will get no warning.
A character written between single quotes represents an integer value equal to the numerical value of the character in the machine's character set. This is called a character constant, although it is just another way to write a small integer. So, for example, 'A' is a character constant; in the ASCII character set its value is 65, the internal representation of the character A.
You should note carefully that '/n' is a single character, and in expressions is just an integer; on the other hand, “/n” is a string constant that happens to contain only one character.
- C复习笔记(2)-6.18
- C语言复习笔记 2
- c复习笔记
- C语言复习笔记
- C语言复习笔记
- C笔记复习
- C--复习笔记
- C & C++ 复习笔记
- C复习笔记(1)-6.16
- C复习笔记(3)-6.19
- C复习笔记(4)-6.20
- C复习笔记(5)-6.23
- C复习笔记(6)-6.24
- C复习笔记(7)-7.4
- C复习笔记(7)-7.4
- c语言复习笔记1
- C语言老师复习笔记
- C语言复习笔记 1
- 图像,log处理的一点经验
- CFileDialog改变系统当前路径的问题
- C复习笔记(1)-6.16
- 数据结构
- VS2005[C#] 操作 Excel 全攻略
- C复习笔记(2)-6.18
- “%@ %”指令
- IIS 6.0中配置HTTP压缩的步骤如下:
- struts用好了 就不愿意用jsp了
- blog开通
- C#读书笔记
- 质量(三)
- 第二人生的源码分析(九十四)LLTextBox类实现文本显示
- 代理服务器 (proxy) 的使用