#include<stdio.h>
int main(){
int a;
scanf("%d", &a);
printf("The value of a is %d", a);
return 0;
}
What my OUTPUT Tab shows in VS Code (When I press the button Run Code):
[Running] cd “c:UserspratyDocumentsThe-Ultimate-C-Programming-Course-mainChapter 1” && gcc 06_input.c -o 06_input && “c:UserspratyDocumentsThe-Ultimate-C-Programming-Course-mainChapter 1″06_input
Besides I have to manually terminate the compilation process, otherwise this keeps running.
What my TERMINAL Tab of VS Code shows is nothing:
PS C:UserspratyDocumentsThe-Ultimate-C-Programming-Course-main
The program below also has the same problem as mentioned below this code.
int main(){
// int length = 3;
// int breadth = 6;
int length, breadth;
printf("Enter lengthn");
scanf("%d", &length);
printf("Enter breadthn");
scanf("%d", &breadth);
printf("The area of this rectangle is %d", length*breadth);
return 0;
}
Both of these programs work fine with hard coded inputs but when it comes to taking inputs from user, it shows these above mentioned things in my OUTPUT Tab and TERMINAL Tab in VSCode.
It is not only about this program but happens with every program where I want user supplied inputs.
I am using VSCode and I am a complete beginner in using VSCode and coding in C Language or any other programming language.
So, I am a complete newbie to an extent that this is my 2nd question on StackOverflow.
So, forgive me for any unintentional error in my question or any kind of unintentional mistake.
This program should have taken user inputs simply and should have given the desired result.
I have seen whole buzz of scanf, sscanf, fgets, some say this works some say that works and that one is dangerous and should never never be used…..but actually I am a complete beginner and I don’t understand nuances of programming or C too.
I have gone through other answers and my problem is a little bit different as my printf function too is not working as it is clear from the image I inserted in my question. Talking about the answers, they were either too technical for me or some didn’t just work.
So, I just want to use scanf only as I have seen tutorials where people do teach in same IDE (i.e., VSCode) the same programming language (i.e., C) and there this scanf works.
Or if there is a simpler alternative to it.
Or do I have problem in my system itself such that it doesn’t even show what I wrote in the printf function.
I searched Youtube and got the solution with the search as : How to input user values in VSCode.
Steps : Open VSCode > Settings > Extensions > Run Code Configuration > Run in Terminal
11