很惭愧,到现在才写自己的第一个c程序!以前服务器做的管理都是用shell来管理,和都是在一直写php 的web程序!一直觉得c都是深不可测,今天决定学习一下c!一下是第一c:helloword
1.编写程序:
保存后编译
-o 编译后的文件名
-g 编译文件名
:D 暂时只知道这些
编译后出错:
貌似是单引号的问题 ,改成双引号
再编译就好了!
运行:
结果:
[code="linux"]# ./firstc
hello word# [/code]
哈哈
1.编写程序:
vi firstc.c
#include "stdio.h"
int main(){
printf('hello word');
}
保存后编译
gcc -o firstc -g first.c
-o 编译后的文件名
-g 编译文件名
:D 暂时只知道这些
编译后出错:
firstc.c:3:9: warning: character constant too long for its type
firstc.c: In function 'main':
firstc.c:3: warning: passing argument 1 of 'printf' makes pointer from integer without a cast
貌似是单引号的问题 ,改成双引号
再编译就好了!
运行:
./firstc
结果:
[code="linux"]# ./firstc
hello word# [/code]
哈哈