使用c写的第一个hello world!
来源:互联网 发布:linux升级ruby版本 编辑:程序博客网 时间:2024/05/16 06:39
我第一次编写的helloworld.c是这样的:
#include <stdio.h>int main(void){ printf('Hello World!\n');}
然后就报错了:
andymini:c andy$ vim helloworld.c andymini:c andy$ gcc helloworld.c helloworld.c:5:9: warning: multi-character character constant [-Wmultichar] printf('Hello World!\n'); ^helloworld.c:5:9: warning: character constant too long for its typehelloworld.c:5:9: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *' [-Wint-conversion] printf('Hello World!\n'); ^~~~~~~~~~~~~~~~/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/stdio.h:257:36: note: passing argument to parameter hereint printf(const char * __restrict, ...) __printflike(1, 2); ^helloworld.c:5:9: warning: format string is not a string literal (potentially insecure) [-Wformat-security] printf('Hello World!\n'); ^~~~~~~~~~~~~~~~4 warnings generated.andymini:c andy$ clearandymini:c andy$ lltotal 40drwxr-xr-x 5 andy admin 170 4 1 22:28 ./drwxrwxr-x 24 root admin 816 4 1 22:26 ../-rwxr-xr-x 1 andy admin 8456 4 1 22:28 a.out*-rw-r--r-- 1 andy admin 66 4 1 22:27 helloworld.c-rw-r--r-- 1 andy admin 8 4 1 22:28 test1.phpandymini:c andy$ ./a.out Segmentation fault: 11andymini:c andy$ vim helloworld.c andymini:c andy$ gcc helloworld.c andymini:c andy$ lltotal 40drwxr-xr-x 5 andy admin 170 4 1 22:29 ./drwxrwxr-x 24 root admin 816 4 1 22:26 ../-rwxr-xr-x 1 andy admin 8456 4 1 22:29 a.out*-rw-r--r-- 1 andy admin 66 4 1 22:29 helloworld.c-rw-r--r-- 1 andy admin 8 4 1 22:28 test1.phpandymini:c andy$ ./a.out Hello World!andymini:c andy$
后面看原来是双引号的问题,改成了这样:
#include <stdio.h>int main(void){ printf("Hello World!\n");}
就可以了!
另外发现vim可以:n test1.php 进行新文档的编写,只要是用:e test1.php或者:e helloworld.c就可以切换回刚刚的文件了,非常方便!
迫不及待的想多写点C代码了~~~
0 0
- 使用c写的第一个hello world!
- 关于我们写的第一个hello world 的由来
- 用VC写的第一个窗口程序 Hello World!
- 用 Python+Django 写的第一个 Hello World 程序
- 用Struts2写的第一个"Hello,World!"
- 自己写操作系统,第一个hello world!
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- 6个变态的C语言写的Hello World
- POJ3692 Kindergarten【二分图最大独立集】
- Android Studio升级后,开启时遇到tools.jar seems to be not in Android Studio错误?
- Ajax笔记
- iOS开发一行代码系列:一行搞定数据库
- Ubuntu nginx部署Wordpress
- 使用c写的第一个hello world!
- Step2 -- 工作环境配置
- cpp反汇编之控制结构
- win32和mfc读写文件
- 习题2-10
- 初学opengl简单总结(一)
- leetcode_num98_Validate Binary Search Tree
- 有人说“ERP将死”,真是这样吗?
- 内存数据校验 Hamming 偶校验 算法及实现