Too few parameters used for the call/Conflict while writing position/Invalid exception handler routine detected

Too few parameters used for the call/Conflict while writing position/Invalid exception handler routine detected

For a class of problems that newcomers may encounter in the process of learning C

We often encounter this situation in our studies:

#include<stdio.h>
void main()
{
    
    
	char note[100] = "";
	scanf("%s", note, 100);//本行会报错提醒我们使用scanf_s代替scanf
}

Many functions with the "_s" suffix are to make the original function more secure. Pass in a value related to the parameter to avoid quoting non-existent elements. Sometimes hackers can use the original insecurity to hack the system. For example: char note[100]; written as scanf_s("%s",note,100); or scanf_s("%s",note,sizeof(note)); is correct, there is this parameter 100 to improve the accuracy .

I listed three common exceptions

  • [1] Too few parameters for calling
  • [2] Conflict occurred while writing location
  • [3] An invalid exception handler routine was detected

在处理这三个异常时可以观察代码是否有这样的错误:

//注释内是错误写法
scanf_s("%s", note,100);//缺少参数100 scanf_s("%s", note);

sprintf_s(temp, sizeof(temp) ,"\n收入\t%s\t\t%.2f\t\t%.2f", note, money, blance);
//缺失参数sizeof(temp)sprintf_s (temp, "\n收入\t%s\t\t%.2f\t\t%.2f", note, money, blance);

strcat_s(data,sizeof(data),temp);//同样缺失参数  strcat_s(data,temp);

Hope to help you who are both novices.

Guess you like

Origin blog.csdn.net/Eric_xkk/article/details/108563892