An access violation occurred while recording the location. That's the error

Asked 2 years ago, Updated 2 years ago, 20 views

#include <stdio.h>

int main(void)
{
    char name[10];

    printf ("Enter Your Name":");
    scanf_s("%s", name);

    printf ("Your name is %s"; name);


    return 0;
}

Why is that?

c++

2022-09-20 20:03

1 Answers

The scanf and scanf_s functions are slightly different in use.

Please refer to the code below.

#include<stdio.h>

int main(void) {
    char name[20];

    printf("Enter your name: ");
    scanf_s("%s", name, sizeof(name));

    printf ("Your name is %s"; name);

    return 0;
}


2022-09-20 20:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.