问题描述
在这段代码中,我面临3个问题。如何摆脱它们?
- 问题1:使用带有&标记的scanf
如果我使用scanf("%s",to_find);
而不使用&
,并且像这样to_find[50]
那样将 to_find 变量设置为等于 50 ,则if语句会不起作用,给我这样的信息exited,segmentation fault
- 问题2:结合使用scanf和&符号
如果我将scanf("%s",&to_find);
与&
一起使用,并像这样to_find[50]
将 to_find 变量设置为等于 50 ,则{{1}像这样显示消息
scanf
而且if陈述也无法运作,给我这样的讯息warning: format specifies type 'char *' but the argument has type 'char (*)[50]'
- 问题3:使用fgets
如果我像这样exited,segmentation fault
使用fgets(to_find,50,stdin);
并将 to_find 变量设置为等于 50 ,则if语句不起作用,给我一条消息像这样to_find[50]
exited,segmentation fault
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)