Warm up:C input and output

本文介绍了一个简单的C语言练习,旨在帮助初学者掌握字符的逐个读取与输出技巧。练习要求从输入中读取一串字符,并将其按字符逐行打印出来。文章提供了示例代码,展示了如何使用while循环结合scanf函数来处理输入直到遇到文件结束符EOF。

谨以此练习来学习最基础的C语言输入和输出。


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);




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值