Setting up the stage for C

·

3 min read

Setting up the stage for C

In this blog post, we will set up everything you need to start coding with C right away. Which is mainly, an IDE.

An Integrated Development Environment (IDE) is a software application that provides a comprehensive set of tools and features to assist developers in writing, testing, and debugging code. IDEs have become an essential part of modern software development due to their numerous advantages and the convenience they offer. Here are some key reasons highlighting the importance of IDEs:

  • Code Efficiency

  • Enhanced Productivity

  • Debugging Capabilities

  • Integrated Build Systems

  • Project Management

  • Language Support

  • Extensibility

We will explore these later on but for now, let's set up Visual Studio 2022 to start working on some C code. Follow these steps:

  1. Download Visual Studio 2022: Visit the official Microsoft Visual Studio website (visualstudio.microsoft.com) and navigate to the downloads section. Look for the Visual Studio 2022 Community edition, which is free for personal use. Click on the download button to begin the download.

  2. Run the installer: Once the download is complete, locate the downloaded installer file and run it. You may need to provide administrative permissions to proceed.

  3. Select workloads: The installer will launch and present you with a list of workloads to install. Workloads are pre-configured sets of tools and components for specific development scenarios. For coding in C, select the "Desktop development with C++" workload. You can also choose additional workloads or components if needed. Click on the "Install" button to continue.

  4. Choose individual components: On the next screen, you can select individual components to install within the selected workload. Make sure to check the box for "C++ CMake tools for Windows" and any other components you may require for your C development. Then click on the "Install" button.

  5. Accept license terms: Read and accept the license terms presented by the installer.

  6. Choose installation location: You can choose the installation location for Visual Studio or keep the default. Select your preferred option and click on the "Install" button.

  7. Wait for installation: The installer will now download and install the selected components. This process may take some time depending on your internet speed and computer performance.

  8. Launch Visual Studio: Once the installation is complete, you can launch Visual Studio 2022 from the Start menu or desktop shortcut. It may take a moment to initialize for the first time.

  9. Create a new C project: In Visual Studio, click on "Create a new project". In the project creation wizard, navigate to "Templates" -> "C++" -> "Console App". Give your project a name, choose a location, and click on the "Create" button.

  10. On the left panel go to "Source Files", right-click, and select "Add"->"New Item". In the new window, you can select "C++ File", but change the name of the file down below to "FileNameHere.c" so the IDE knows it's a C file.

  11. Start coding: Visual Studio will create a new C project for you with a default source file. A default "Hello, World!" code will be on your editor. You can start coding in the editor window. Write your C code, save the file, and use the build and run commands to compile and execute your program.

PS: All C code is also C++ code because C++ builds on top of C. This is also why we created a C++ project because they are practically the same. But it's important to name file extensions(.c, .cpp, etc.) properly.

That's it! You have now downloaded and set up Visual Studio 2022 for coding in C. Happy coding!