C6064: missing integer argument to <function> corresponding to conversion specifier <number>

-3
#include <stdio.h>
int main(){
char s[10];
scanf_s("%s", s);
for (int i = 0; i < 10; i++)
    printf("%s\n", s);
}

This error appears in visual studio

Exception thrown at 0x7B8BEF1C (ucrtbased.dll) in 1.exe: 0xC0000005: Access violation writing location 0x00942000.enter image description here

c
visual-studio
asked on Stack Overflow May 23, 2021 by Islam.Abdelbakey • edited May 24, 2021 by Islam.Abdelbakey

1 Answer

1

You're missing arguments. The proper usage is

scanf_s("%s", s, 10);

or

scanf_s("%9s", s, 10);

(These are slightly different.)

You should also check the value returned before using s.

Ref

answered on Stack Overflow May 23, 2021 by ikegami

User contributions licensed under CC BY-SA 3.0