您的位置:首页 > 编程语言 > C语言/C++

C 语言基础-初识

2018-03-08 15:37 232 查看

1.为什么要使用 C?

C 语言所产生的代码运行速度与汇编语言编写的代码运行速度几乎一样

2.C 环境设置

2.1 Linux 查看

gcc -v

使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
目标:x86_64-linux-gnu
配置为:../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
线程模型:posix
gcc 版本 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)


2.1 Window下安装

Minimal GNU on Windows 主页 www.mingw.org,的下载地址

https://sourceforge.net/projects/mingw/?source=typ_redirect

mingw-get-setup.exe

3.Hello World

示例

HelloWorld.c

# include <stdio.h>

int main()
{
printf("%s\n", "Hellow world");
return 0;
}


运行

1. 编译 gcc HelloWorld.c,生成默认执行文件名

2. 运行 ./a.out

suhuazhi@chenxiaoping-PC:~/C_Study/HelloWorld$ gcc HelloWorld.c
suhuazhi@chenxiaoping-PC:~/C_Study/HelloWorld$ ls
a.out  HelloWorld.c
suhuazhi@chenxiaoping-PC:~/C_Study/HelloWorld$ ./a.out
Hellow world
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息