用GCC编译调试第一个C程序

本文记录了作者在Linux环境下使用GCC编译C程序的过程,包括遇到的错误和解决方法。在尝试编译运行一个简单的C程序时,遇到了未声明变量、函数参数不匹配以及原型声明错误。经过修改后,程序最终成功运行并展示了输入和输出功能。
摘要由CSDN通过智能技术生成

今天终于迈出了自己LINUX下写C的第一步,在VI下写的程序,在GCC下面编译链接的,VI的使用比较不方便,目前还不太习惯。

fei@fei-pc:~$ vi test.c
fei@fei-pc:~$ vi test.c
fei@fei-pc:~$ gcc -o test test.c
test.c:9: error: ‘N’ undeclared here (not in a function)
test.c: In function ‘main’:
test.c:42: error: too few arguments to function ‘input’
test.c:43: error: too few arguments to function ‘print’
fei@fei-pc:~$ vi test.c
fei@fei-pc:~$ gcc -o test test.c
test.c: In function ‘printf’:
test.c:29: error: number of arguments doesn’t match prototype
/usr/include/stdio.h:339: error: prototype declaration
fei@fei-pc:~$ vi test.c
fei@fei-pc:~$ gcc -o test test.c
fei@fei-pc:~$ ./test

 please input 1 of 5
num: ^[[4~
name: try
score 1.45
score 2.45
score 3.45


 please input 2 of 5
num: ^[[1~
name: dfs
score 1.89

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值