How to write ANSI C programs by using Visual C++

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 you.

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:
  1. Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
  2. On the File menu, point to New, and then click Project.
  3. Under Project Types, click Visual C++ Projects.

    Note In Visual Studio 2005, click Visual C++ underProject Types.
  4. Under Templates, click Win32 Project.
  5. In the Name text box, type FirstApplication.
  6. In the Location text box, type C:\Test, and then click OK.

    The Win32 Application Wizard - FirstApplication dialog box appears.
  7. In the Win32 Application Wizard dialog box, clickApplication Settings in the left pane.
  8. 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 emptymain function.
    • Windows application: Creates a simple Microsoft Windows-based application. The application files include aProjectName.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.
    To create a simple "Hello World!" program, click to select Console application.
  9. Under Additional options, click to select theEmpty 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.
  10. Click Finish.
  11. In Solution Explorer, right-click the Source Files folder, point toAdd, and then click Add New Item.
  12. In Add New Item - FirstApplication dialog box, clickC++ File (.cpp) under Templates.
  13. In the Name text box, type Test.c, and then click Open.
  14. In the Test.c code window, paste the following code:
    #include <stdio.h>
    
    int main()
    {
    	printf("Hello World\n");
    	return 0;
    }
    #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.
  15. On the Build menu, click Build Solution.
  16. Press CTRL+F5 to run the application. You receive the following message in a Command Prompt window:
    Hello World
    Press any key to continue

http://support2.microsoft.com/kb/829488/en-us

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值