Throwing out an exception error when using %s

-1

Is my code wrong or have I set up visual studios wrong?

https://gyazo.com/e97b40a549968ccd5b452ceb8624ab9f

#include <stdio.h>

int main() {

    int Age;
    char Name[20];

    printf("Hello, what's your Name: ");
    scanf_s("%s", &Name);

    printf("Hello, what's your age: ");
    scanf_s("%d", &Age);

    if (Age < 1)
        printf("Enter a valid age!");

    else 
    printf("Your name is %s.", Name);
    printf("Your age is %d.", Age);

}

I've inserted a GIF showing the error.

"Exception thrown at 0x0F2AD4EC (ucrtbased.dll) in Project5.exe: 0xC0000005: Access violation writing location 0x009D0000. occurred"

c
asked on Stack Overflow Mar 3, 2019 by Pablo • edited Mar 3, 2019 by Arkadiy

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0