Jungletronics
Published in

Jungletronics

VS Code — How to Run C Right Away!

A light IDE, Finally!— Thank God, Bye MS VS Community App #CSeries — Episode #00

Welcome! in this post we will see how we can set up the Visual Studio Code for writing and executing the C/C++ programs.

Fig 1. VS Code Logo

1#Step — You Will need:

tdm-gcc
visualstudio.com

These are the C and C++ toolset and Visual Studio Code installer.

2#Step — So now first let us open up the Visual Studio code; you must install these extensions:

C and C++
Code Runner
Fig 2. One helps with context syntax and the other offers buttons to easily run the code. 2 Essential Hand Tools Every IDE Should Offer, right?

Restart the Visual Studio code.

3#Step — Add a new workspace; Here we will gonna call it as C C++ WS; Save the folder inside this WS;

Let us create a file inside this folder vscode:

Fig 3. I create a folder, vscode, and name my workspace as c c++ ws. Just close the workspaces and File -> Add Folder to Workspace... This will create a new workspace called UNTITLED (WORKSPACE) with chosen folder. File -> Save Workspace as... if you want to save it [link]. That’s it!

Now Let’s get some code!

4#Step — We will create a simple program like this (helloworld.c):

#include<stdio.h>int main(){
printf("Hello World!");
return 0;
}

To run this code first please open the PowerShell As Administrador and Give it permission (why?); Use the prompt :)

Type:

Set-ExecutionPolicy AllSigned
Fig 4. Giving PowerShell permissions, after trying on dry floor…lol

5#Step — Run the code now by pressing this button!

Fig 5. To run the c code, just click this button!

6#Step — Now How to Take Input? As the output tab is read-only let’s make another program to take it and seehow to get around this issue...

To get some user input, let us run this program (getinput.c) to force entry:

#include<stdio.h>int main(){
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("Your age is: %d", age);
return 0;
}

7#Step — Final step: Modify The Settings — You almost there! okay now we have to modify some settings so that this program can take some user input.

Go to:

File > Preferences > Settings > Extensions > scroll down a bit:Run Code Configuration > Run in terminal (check this one)
Fig 6. Authorizing the terminal to receive inputs…

Come back to the code and right click the button again to run the code.

Now the code will run in the terminal :)

Fig 7. …and we can easily offer our age lol o/

That’s all, folks! Hope that helps!

The reason I made the effort to bring this to you is that I wasted time trying to run the C code. I hope that in 3 or 4 minutes you start coding…this app is awesome, even Python can be run on it…click on it and a window will pop up instantly!

Thank you for reading.

I’ll see you later in the next post about C (searching algorithms)!

Bye!

👉Code link

References & Credits

Posts Related:

00 Episode#CSeries — VS Code — How to Run C Right Away! A light IDE, Finally! — thank god, Bye MS VS Community app (this one)

01 Episode#CSeries — MUSIC ALBUM_V2.C — This is a Deque in C — Searching Algorithms Studies

02 Episode#CSeries — Hash tables in C — This is a HashTable in C — Searching Algorithms Studies

03 Episode#CSeries — University Catalog V1 — This is a HashTable — Searching Algorithms Studies

04 Episode#CSeries — Bubble Sorting (Ascendant Algorithm) — This is a Simple Sorting — Searching Algorithms Studies

05 Episode#CSeries — Quick Sorting (Ascendant Algorithm) — This is a Quick Sorting — Searching Algorithms Studies

06 Episode#CSeries — Linear Search — This is a Linear — Searching Algorithms Studies

07 Episode#CSeries — Doubly Linked List — Searching Algorithms Studies(this one)

That’s All, Folks!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store