用C的输入处理 [英] Dealing with input in C

查看:129
本文介绍了用C的输入处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题真的,寻找,想了解一下,并要求最好的办法就是处理这种类型的输入什么任何提示:

A brief question really, looking for, wondering about, and asking for any tips for what the best way is to handle this type of input:

 word word
 word word word word
 word word word
 word word

由此词语的每行的数目是完全随机的,并且每个单独字可以加入到一些数据结构,像一个链表或树例如

whereby the number of words on each line is totally random, and each separate word can be added to some data structure, like a linked list or tree for example.

FGETS每一行和解析?的getchar()?任何线索?

Fgets each line and parse? Getchar()? Any clues?

推荐答案

读取一行与与fgets 一时间似乎是这里最好的选择。然后,只需使用 strtok的或类似的由空的空间分割和迭代的结果。事

Reading one line at a time with fgets seems like the best option here. Then just use strtok or something similar to split by empty space and iterate over the result.

这篇关于用C的输入处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆