第一个unix c程序

一、开发步骤

      1)vi   helloworld.c

      2)gcc   helloworld.c  -ohelloworld

      3)./helloworld


二、第一个unix c程序


      

#include <stdio.h>

int main(){
   printf("helloworld,we like zhangzetian  \n ");

   return 0;
}

解释

   1)#include <stdio.h> 。以#打头的成为预处理行,它会将<>里面文件的内容插到这一行上

    2)int main()。c程序的入口。常见的格式还有 main()   、 void  main() 。其中第一种是标准格式,第二种利用了潜规则,第三种虽然可以,但是不推荐使用。

    3)printf()。格式化打印。print是打印的意思,f表示格式化。

     4) \n。转义字符,换行。常见的转义字符还有\r(回车)    \t(制表符)   \b(退格)   \\(反斜杠) 

你可能感兴趣的:(c,unix,helloworld)