首页 > 其他 > 详细

C programming tutorial 笔记

时间:2018-10-12 20:32:32      阅读:152      评论:0      收藏:0      [点我收藏+]

tutorial 3


 

使用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 运行

 

 tutorial 10


 

#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;

  

  

 

 

 

 

参考内容:


 

C Programming Tutorials

C programming tutorial 笔记

原文:https://www.cnblogs.com/hardi/p/9780260.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!