1. 启动vc++6.0.
2. 在D创建一个文件夹C1_01,用于保存程序文件。
4. 编写程序。
5. 编译(Compile)、链接、运行程序。
二、实验1:
/*
程序功能:输出Welcome to C World!
注释作用:理清思路和方便阅读
*/
#include<stdio.h>
int main()//main是c语言的主函数,int是整型
{
// “\n”表示回车换行
printf("Welcome to C World!\n");
return 0;//返回值为0
}
--------------------Configuration: hello - Win32 Debug--------------------
Compiling...
hello.cpp
hello.obj - 0 error(s), 0 warning(s)
产生了一个目标文件:hello.obj
7.链接(build)
--------------------Configuration: hello - Win32 Debug--------------------
Linking...
hello.exe - 0 error(s), 0 warning(s)
产生一个文件:hello.exe
8. 运行(BuildExecute):符号:感叹号
9. 调试:改正错误
(1)C语言区分大小写。
错误:int Main()
编译:hello.obj - 0 error(s), 0 warning(s)
链接:
--------------------Configuration: hello - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/hello.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
hello.exe - 2 error(s), 0 warning(s)
(2)标点符号必须使用英文。
错误:printf(“Welcome to C World!\n”);
分析错误:
--------------------Configuration: hello - Win32 Debug--------------------
Compiling...
hello.cpp
D:\CProgram\hello.cpp(11) : error C2018: unknown character '0xa1'
D:\CProgram\hello.cpp(11) : error C2018: unknown character '0xb0'
D:\CProgram\hello.cpp(11) : error C2065: 'Welcome' : undeclared identifier
D:\CProgram\hello.cpp(11) : error C2146: syntax error : missing ')' before identifier 'to'
D:\CProgram\hello.cpp(11) : error C2017: illegal escape sequence
D:\CProgram\hello.cpp(11) : error C2018: unknown character '0xa1'
D:\CProgram\hello.cpp(11) : error C2018: unknown character '0xb1'
D:\CProgram\hello.cpp(11) : error C2059: syntax error : ')'
Error executing cl.exe.
hello.obj - 8 error(s), 0 warning(s)
正确: printf("Welcome to C World!\n");