有什么方法可以从stdin中输入一个单词作为输入吗? [英] Any way to take a word as input from stdin ?
问题描述
我搜索了Google提供的c.l.c档案,其中包含
" word input"作为关键词并没有提出任何好的东西。
C ++有std :: string用于从stdin中输入一个单词作为输入。 C以两种方式输入
:
1)作为一个字符,etchar()
2)作为一个整行,fgets()
作为C程序员,我们应该每次创建一个get_word函数
当我们需要一个单词作为stdin的输入时(例如终端)
-
www.lispmachine.wordpress.com
我的电子邮件是@上面的博客。
谷歌群组被阻止。原因:过度垃圾邮件
9月10日下午1:08,arnuld< sunr ... @ invalid.addresswrote:
我搜索了Google提供的clc档案,其中包含
" word input"作为关键词并没有提出任何好的东西。
C ++有std :: string用于从stdin中输入一个单词作为输入。 C以两种方式输入
:
1)作为一个字符,etchar()
2)作为一个整行,fgets()
作为C程序员,我们应该每次创建一个get_word函数
当我们需要一个单词作为stdin的输入时(例如终端)
char word [64];
scanf("%63s",word);
或者,写一个get_line函数(或者使用pete编写的函数,
richard heathfield,eric sossman,cbfalconer等等),然后分成
。
arnuld< su ***** @ invalid.addresswrote:
C ++有std ::用于从stdin获取输入的字符串。 C以两种方式输入
:
1)作为一个字符,etchar()
2)作为一个整行,fgets()
作为C程序员,我们应该每次创建一个get_word函数
当我们需要一个单词作为stdin的输入时(例如终端)
没有通用的解决方案(主要是因为没有达成共识
是什么字),所以是的。
Richard
" arnuld" < su ***** @ invalid.addresswailed in message
作为C程序员,我们是否应该每次都创建一个get_word函数
当我们需要一个单词作为stdin的输入时(例如终端)
通常会有一个正则表达式解析器可用。遗憾的是,这不是标准库的一部分
,因此细节可能会有所不同。
您可以准确地指出单词的含义,用它来提取。
-
免费游戏和编程好东西。
http://www.personal.leeds.ac.uk/~bgy1mm
I searched the c.l.c archives provided by Google as Google Groups with
"word input" as the key words and did not come up with anything good.
C++ has std::string for taking a word as input from stdin. C takes input
in 2 ways:
1) as a character, etchar()
2) as a whole line, fgets()
as C programmer, are we supposed to create a get_word function everytime
when we need a words as input from stdin ( e.g. terminal)
--
www.lispmachine.wordpress.com
my email is @ the above blog.
Google Groups is Blocked. Reason: Excessive Spamming
On Sep 10, 1:08 pm, arnuld <sunr...@invalid.addresswrote:I searched the c.l.c archives provided by Google as Google Groups with
"word input" as the key words and did not come up with anything good.
C++ has std::string for taking a word as input from stdin. C takes input
in 2 ways:
1) as a character, etchar()
2) as a whole line, fgets()
as C programmer, are we supposed to create a get_word function everytime
when we need a words as input from stdin ( e.g. terminal)char word[64];
scanf("%63s", word);
Alternatively, write a get_line function (or use one written by pete,
richard heathfield, eric sossman, cbfalconer et cetera) and then split
that into words.
arnuld <su*****@invalid.addresswrote:
C++ has std::string for taking a word as input from stdin. C takes input
in 2 ways:
1) as a character, etchar()
2) as a whole line, fgets()
as C programmer, are we supposed to create a get_word function everytime
when we need a words as input from stdin ( e.g. terminal)There is no generic solution (mainly because there is no consensus on
what a "word" is), so yes.
Richard
"arnuld" <su*****@invalid.addresswrote in messageas C programmer, are we supposed to create a get_word function everytime
when we need a words as input from stdin ( e.g. terminal)
Generally there will be a regular expression parser available. It''s not part
of the standard library, unfortunately, so the details may vary.
You can specify exactly what you mean by a ''word'', and extract with that.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
这篇关于有什么方法可以从stdin中输入一个单词作为输入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!