tomatosoup04
tomatosoup04

Reputation: 11

Why does my VScode not work when I input scanf?

So I'm new to coding overall and I'm using VScode, but in one of the user input tutorial I'm watching require the use of scanf(), but for some reason my code refuses to work, can someone help me!

#include <stdio.h>
#include <stdlib.h>

int main()
{

    int Age;
    {
    printf("Enter your age: \n");
    scanf("%d", &Age);
    printf("you are %d years old", Age);
    }
    return 0;
}

and after I press the run code button, all I get is just

[Running] cd "/Users/Spanecon/IDK WTF/" && g++ tempCodeRunnerFile.cpp -o tempCodeRunnerFile && "/Users/Spanecon/IDK WTF/"tempCodeRunnerFile

but nothing else comes up. Can someone help me please?

Upvotes: 1

Views: 525

Answers (1)

Unmitigated
Unmitigated

Reputation: 89224

Since input is required, you could install the Code Runner extension for this.

Set it to run code in the terminal through an option in settings.json:

{
    "code-runner.runInTerminal": true,
}

To run the code, right click and select "Run Code" (Ctrl + Alt + N). Enter the input in the terminal thereafter.

Upvotes: 0

Related Questions