Warm up:C input and output
2017-10-16 15:37
218 查看
谨以此练习来学习最基础的C语言输入和输出。
This is an exercise for you to get prepared for C language programming.
All you have to do is to accept a string as input, and print it character by character. Characters are separated by new line.
The difficulty lies in deciding wether the string ends or not, and 'EOF' is used to solve the problem(see hint).
A string.
Print those characters of the given string, one character per line.
Kernel code:
char ch;
while(scanf("%c",&ch) != EOF) {
// DO SOMETHING
}
Description
This is an exercise for you to get prepared for C language programming.All you have to do is to accept a string as input, and print it character by character. Characters are separated by new line.
The difficulty lies in deciding wether the string ends or not, and 'EOF' is used to solve the problem(see hint).
Input
A string.
Output
Print those characters of the given string, one character per line.
Sample Input
Hi!
Sample Output
H i !
HINT
Kernel code:char ch;
while(scanf("%c",&ch) != EOF) {
// DO SOMETHING
}
#include <stdio.h> //头文件,标准输入输出 #include <stdlib.h> int main() { int ch; while(scanf("%s",&ch)!=EOF){ printf("%s\n",ch);}; return(0);
相关文章推荐
- Lua 标准库 - 输入输出处理(input and output facilities)
- File Input and Output(1)
- Section 6: Redirecting Input and Output
- How to check the 'OLE DB Destination' INPUT and OUTPUT
- 1.5.输入和输出(Input and Output)
- Input and Output
- 7. Input and Output
- python tutorial 学习笔记(四) Input and Output, 字符串的转换等
- [quote] standard Input and Output Redirection
- Python input and output
- The Python Tutorial - Input and Output
- 《modern operating system》 chapter 5 Input and output 笔记
- C Standard Library: 1 Input and Output: <stdio.h>
- The C programing language chapter 7 : Input and Output
- Reading and writing files in Java (Input/Output) - Tutorial
- Python Intro - System Input and Output
- 8 Input and Output
- 5-v4l2——input and output输入输出
- Lua 标准库 - 输入输出处理(input and output facilities)
- Data input format and Data output format