This step-by-step article describes how to write American National Standards Institute (ANSI) C programs by using Microsoft Visual Studio .NET. This article discusses how to write a simple "Hello World!" C program by using Visual C++ application wizards in the Visual Studio .NET or Visual Studio 2005 IDE.
To create ANSI C programs by using the Visual C++ application wizards in the Visual Studio .NET or Visual Studio 2005 IDE, follow these steps:
- Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
- On the File menu, point to
New, and then click Project.
- Under Project Types, click Visual C++ Projects.
Note In Visual Studio 2005, click Visual C++ under Project Types.
- Under Templates, click Win32 Project.
- In the Name text box, type
- In the Location text box, type
C:\Test, and then click OK.
The Win32 Application Wizard - FirstApplication dialog box appears.
- In the Win32 Application Wizard dialog box, click Application Settings in the left pane.
- Under Application Type, click to select any of the following options:
- Console application: Creates a simple console application. The application files include a .cpp file that contains an empty main function.
- Windows application: Creates a simple Microsoft Windows-based application. The application files include a
ProjectName.cpp file that contains a
_tWinMain function. You can use this type of application to perform graphical user interface (GUI) based programming.
- DLL: Creates a 32-bit Windows-based DLL application project.
- Static library: Creates a 32-bit Windows-based DLL application project.
- Under Additional options, click to select the Empty project check box.
Note To create a simple "Hello World!" program, do not select this check box. Instead, let the wizard generate the code for you.
- Click Finish.
- In Solution Explorer, right-click the Source Files folder, point to Add, and then click Add New Item.
- In Add New Item - FirstApplication dialog box, click C++ File (.cpp) under Templates.
- In the Name text box, type Test.c, and then click Open.
- In the Test.c code window, paste the following code:#include is a preprocessor directive that tells the compiler to put code from the stdio.h header file into your program. If you include header files, you can gain access to standard library functions. For example, your application must have access to the stdio.h header file to use the printf function.
- On the Build menu, click Build Solution.
- Press CTRL+F5 to run the application. You receive the following message in a Command Prompt window:
For more information, visit the following Microsoft Developer Network (MSDN) Web sites:
Article ID: 829488 - Last Review: Feb 15, 2017 - Revision: 2