当前位置:网站首页>Use of the vs2022scanf function. An error is reported when using scanf - the return value is ignored: Solutions

Use of the vs2022scanf function. An error is reported when using scanf - the return value is ignored: Solutions

2022-06-23 19:47:00 51CTO

scanf() yes C Language format input function , and printf Functions are also known in studo.h In the header file , Used here scanf function , Simple summation example , as follows vs2022scanf Use of functions , Use scanf The error of - The return value is ignored : solve · Method _ compiler


In the seventh line of the current program , We used scanf Function , Then wait for the user's input , It accepts the address of the variable , So in general, in addition to pointer variables and array names, you must add &. Don't forget to &, Don't forget to &, Don't forget to &!!!

scanf Call format for (“”,);

After running, press the following mode to output num1,mum2 Value

It should have been a normal process

however

Report errors :“scanf” The return value is ignored

I searched the Internet , Successfully solved

You need to prefix the entire code with

define _CRT_SECURE_NO_WARNINGS

Running successfully , The following are successful examples vs2022scanf Use of functions , Use scanf The error of - The return value is ignored : solve · Method _ Array name _02

Careful students will find that I use “scanf_s” function , instead of "scanf"

Because the return value is ignored scanf It is because... Is not used in the code scanf The return value of , Need to use scanf_s Instead of a function scanf,scanf yes C Language provides , and scanf_s Not the standard C Language provides , yes vs Compiler provided , Finally, the program finally runs .



原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231833088602.html