为什么scanf输入字符串时报错
时间: 2023-08-27 13:14:26 浏览: 163
cin和scanf输入错误的处理
4星 · 用户满意度95%
scanf输入字符串时报错可能有几个原因。首先,如果使用scanf函数而不是scanf_s函数,在某些编译器中可能会被认为是不安全的,因此可能会报错。这就是为什么在vs中建议使用scanf_s函数的原因。改为char a,这样就可以容纳最多20个字符的输入。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [C语言:VS中利用scanf_s函数输入字符串时出错](https://blog.csdn.net/H_yufu/article/details/122566654)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [解决scanf_s函数输入字符串无报错,但是printf为空](https://blog.csdn.net/qq_47757966/article/details/121881627)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文