使用linux系统运行c,
安装gcc,为compiler,使用vim等工具写好hello world程序,命名hello.c
#include <stdio.h> int main(){ //int means the returned data type printf("hello world!\n"); // \n means a new line return 0; //the program worked as expected }
之后在terminal中输入:gcc hello.c,之后会自动生成a.out文件,然后输入 ./a.out 运行
#include <stdio.h> int main(){ int x = 10; int y = x/2; printf("the magic number is: %i\n",y); //"", is a format string, and %i inside means it‘s an integer, \n is new line, y is the variable you want to print printf("the magic number is: %i\nThe value x is: %i\n",y,x);//this will work too, first string,y and x are arguments return 0; }//the first output is 5;
参考内容:
原文:https://www.cnblogs.com/hardi/p/9780260.html