Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code. Microsoft Visual C++ 2005 supports both the managed code
model that is provided by the Microsoft .NET Framework and the unmanaged native
Microsoft Windows code model.
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.
The best way to create new projects is by using the Visual
C++ application wizards. Visual C++ application wizards work with the application frameworks and libraries to create starter programs for
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
Note In Visual Studio 2005, click Visual C++ under Project Types.
- Under Templates, click Win32
- 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:
To create a simple "Hello World!" program, click to select
- 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
- 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
- Press CTRL+F5 to run the
application. You receive the following message in a Command Prompt window:
For additional information about the C1010 compiler error, click the following article number to view the article in the Microsoft Knowledge Base:
INFO: Most Common Causes of C1010 Error
For more information, visit the following Microsoft
Developer Network (MSDN) Web sites:
Article ID: 829488 - Last Review: April 19, 2007 - Revision: 3.2
- Microsoft Visual C++ 2005 Express Edition
- Microsoft Visual C++ .NET 2003 Standard Edition
- Microsoft Visual C++ .NET 2002 Standard Edition
|kbsample kbcode kbprogramming kbwizard kbhowto KB829488|