如何使用 scanf 读取空格? [英] How do I read in white spaces with scanf?
本文介绍了如何使用 scanf 读取空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它在看到空格后完全停止读取代码.如何更改我的代码以使其以空白读取
It completely stops reading in code after it sees a space. How do I change my code so it reads in white space
char line[300];
printf("Enter a string to be checked: ");
scanf("%s", line);
我试图通过重定向输入的字符串是:
the string I'm trying to input via redirection is:
( ( a a ) <> [ [ [ { [ x ] ]]] <>)
( ( a a ) < > [ [ [ { [ x ] ]]] <>)
推荐答案
可以使用 scanf 的 fgets intsead.例如:
You can use fgets intsead of scanf. For example:
fgets(line, 1024, stdin);
这篇关于如何使用 scanf 读取空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文