为什么scanf不工作? [英] Why scanf not working?

查看:94
本文介绍了为什么scanf不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我想要扫描两个字符串(多个),但它只扫描第一个字符串而不要求second.it打印输出而不扫描第二个字符串为什么?



我尝试过:



 scanf(%[^ \ n] s ,S1); 
scanf(%[^ \ n] s,s2);
printf(%s \ n,s1);

printf(%s \ n,s2);



输出

输入两个字符串
sndn sdnson
sndn sdnson
*

解决方案

可能是一些线索这里 [ ^ ]

here i want to scan two strings(multiple) but it just scan only the first one and does not ask for second.it printsout the output without scanning the second string why?

What I have tried:

scanf("%[^\n]s",s1);
scanf("%[^\n]s",s2);
printf("%s\n",s1);

printf("%s\n",s2);


OUTPUT

enter two strings
sndn sdnson
sndn sdnson
*

解决方案

Possibly some clues here[^].


这篇关于为什么scanf不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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