C程序设计实验1

一、实验步骤:


1. 启动vc++6.0.

2. 在D创建一个文件夹C1_01,用于保存程序文件。


3. 在VC++中,新建--C++source file,指定存盘的位置为D:\C1_01,文件名为hello.c。


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");










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值