Making Your First C++ Program (Windows)

Hello aspiring coders! Do you want to be able to tell your friends that you have made a program? Maybe you are just looking for a good place to get started to see if this would be an interesting hobby? It doesn't matter how familiar you are with navigating a computer as this guide will be friendly enough for even the most conservative tech users! With this guide you will learn how to install the necessary software and learn how to execute a program with sample code provided.

**You may need to restart your computer during this instructable**

Step 1: Download and Install Visual Studio Build Tools

Just click this link and the download will begin automatically. Wait for the download bar to finish and run the file you just downloaded.

Step 2: Install the C++ Build Tools

When your Visual Studio install is complete, you will now need to install the Visual C++ build tools. Without these your application will not be able to understand your program.

A restart may be required, if so, make sure you don’t have anything else important running and hit the “Restart” button on the Installer.

**This is the only step where a restart may be required.**

Step 3: Launch the Visual Studio Build Tools

Now you can launch the Visual Studio command line, this is where you will be running your code once it is complete.

For now, you can just minimize it as we will be using it later.

Step 4: Download and Install Notepad++

Click this link here to go to the website and hit the download button for Notepad++

You don't need to pay much attention to where it is installing until you come to the fourth screen, where it will give you an option to create a desktop shortcut. Check this box for easy access to Notepad++

Going through the windows you will select Next > I Agree > Next > Next then you will be at the window to select to Create Shortcut on Desktop> Install

Step 5: Create a Folder on Your Desktop

Now you will need to navigate to your desktop and make a folder so you can easily access the code you will be using. To do this you just need to minimize your windows and right click on any open space on your desktop. Select New > Folder and name it C++

Step 6: Open Notepad++

While you are on your desktop, double click on the Notepad++ and delete the text that automatically appears on it. This is where you will be able to write code in the future, but for today you can use the code provided below.

Copy the code and paste it into Notepad++

#include
#include

using namespace std;

int main (int argc, char** argv) {

cout << "Congrats The Program has ran." << endl;

cout << "The Test is over now." << endl;

return 0;

}

Navigate to the menu at the top left of Notepad++ and choose File > Save As...

Step 7: Save Your Code

Here you will need to select Desktop and find the folder named C++ that you made earlier, double click on the folder to go inside it.

Name your file SourceCode.cpp and hit Save

Step 8: Reopen the Developer Command Prompt

You remember the Visual Studio Command Prompt you minimized earlier? We need it now, bring it back up and are about to change a lot of directories. In order to find our program, you will need to navigate to the folder you made on your desktop where you saved your file. To do this you will need to change your directory using the command cd. Start by typing cd C:\ and hit enter.

Step 9: Navigate to the C++ Folder

Next type cd Users and hit enter.

Then you will need to type cd *username* your username will be whatever the name of the profile you are on is, which is the name you see on the lock screen when you turn your computer on. My profile is named "Shawn" since that is my name, yours will likely be different. On Windows you can hit the Windows button in the bottom left and hover over the person icon in the bottom left to find out what the profile's name is.

Now you will enter cd Desktop and hit enter.

Step 10: Find Your C++ Program

Next type cd C++ and hit enter.

Now we are in the folder on your desktop where the saved file is.

Step 11: Compile Your Program

Now that we have found the folder, we will need to compile it. In the command prompt type cl SourceCode.cpp

Once you hit enter a lot of text will appear in the terminal and look like the image above.

Step 12: Run Your Program

Now for the big finish! All there is left to do is run the program. Type SourceCode.exe into the prompt and lay your witness the fruits of your labor.

Share

    Recommendations

    • Tape Contest

      Tape Contest
    • Arduino Contest 2019

      Arduino Contest 2019
    • Trash to Treasure

      Trash to Treasure

    Discussions