如何在do..while()循环中使用gets()函数? [英] How do I use gets() function inside do..while() loop?
本文介绍了如何在do..while()循环中使用gets()函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
执行一个循环后,'gets()'函数在'do ... while'循环内无效
the 'gets()' function is not working inside a 'do ...while' loop after one cycle of execution
推荐答案
首先,不要不要使用gets()
,而是使用getline()
。请参阅 http://www.crasseux.com/books/ctutorial/gets.html [ ^ ]。
在 getline()的示例> http://www.crasseux.com/books/ctutorial/getline.html#getline [ ^ ]。
干杯
Andi
First of all, don't usegets()
, usegetline()
instead. See http://www.crasseux.com/books/ctutorial/gets.html[^].
See an example ofgetline()
at http://www.crasseux.com/books/ctutorial/getline.html#getline[^].
Cheers
Andi
add getchar();就在循环结束之前。
add getchar(); just before the loop ends.
而不是使用gets()使用fgets(),因为gets()可能导致缓冲空间超过运行。
instead of using gets() use fgets() as gets() may results in buffer space over run.
这篇关于如何在do..while()循环中使用gets()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文