How to Run C Program in Visual Studio

How to Run C Program in Visual Studio thumbnail
How to Run C Program in Visual Studio

The C programming language is one of the most powerful computing languages because of its flexibility of syntax and portability. C has contemporary applications in the fields of micro-computing and mathematics. Running a simple C program with Microsoft' s Visual Studios is an essential skill for any professional computer programmer. In a few easy steps you will possess the power of C, and be able to build, compile, link and run your very own C program.

Things You'll Need

  • Microsoft Visual Studios
Show More

Instructions

    • 1

      Open Visual Studios; in the start-up screen go to “File” > “New” > “Project." In the project window make sure to select your project as a Win32 Console Application. Title your project and choose a destination to save it in.

    • 2

      Wait for the application window to pop up; when it does choose the project to be a console application. Select "empty project" and make sure to deselect "pre-compiled header." A pre-compiled header is not suitable for a C program.

    • 3

      Find the project window on the left hand side of your screen. Right click on the source files folder and go “Add” > “New Item." Name your file and remember to change the extension “.cpp” to “.c”, as “.cpp” is for C++ programs.

    • 4

      Type or copy your test program into the main window of Visual Studios. If you do not know how to program in C already, an example of a decent test program is as follows:

      #include <stdio.h> //accesses the printf() function
      #include <conio.h> //accesses the getch() funtion

      void main()
      {
      printf(“hello world\npress any key to exit\n”);
      getch();//waits for key from user and then exits program
      }//end main

    • 5

      Find the green "Play" button in your Visual Studios tool box, press it and your program will automatically link, compile and run. Once the program has run through all its commands, it will exit on its own.

Tips & Warnings

  • A win32 Console application is also known as a Dos Box.

  • Header or “.h” files are not necessary for this tutorial.

  • If you are in college or university you might be able to get a free copy of Microsoft's Visual Studios from Microsoft's Dreamspark website, as listed below in the Resources section.

Related Searches:

References

Resources

  • Photo Credit Ciaran Griffin/Lifesize/Getty Images

Comments

You May Also Like

Related Ads

Featured