0
点赞
收藏
分享

微信扫一扫

C语言-第1章_导言-01

第1章 导言 -01

1.1 入门

// 学习一门新程序设计语言的唯一途径就是使用它编写程序。

// 请打印出下列内容
hello, world

// 要实现这个目的,我们首先必须编写程序文本,然后成功地进行编译,并加载、运行,最后输出到某个地方。

# include <stdio.h>
int main()
{
printf(hello, world\n);

return 0;
}

// 然后再通过下列命令进行编译 -- 我的系统是 deepin 20.8
$ gcc --version
$ cat hello.c
$ gcc hello.c
$ ./a.out



# include <stdio.h> -- 告诉编译器在本程序中包含标准输入/输出库信息
printf(hello, world\n); -- 使用函数名加上圆括号括起来参数表即可

入门 01.png

// printf 函数永远不会自动换行

# include <stdio.h>
int main()
{
printf(hello, );
printf(world);
printf(\n);

return 0;
}


// 然后再通过下列命令进行编译
$ cat hello2.c
$ gcc hello2.c
$ ./a.out

入门2 02.png

参考书籍

-- 书名: C程序设计语言

-- 作者:布莱恩.W.克尼汉 丹尼斯.里奇
举报

相关推荐

0 条评论