<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                # 前言 該系列文章適合于一些有開發經驗卻不太懂 C 的程序員,比如大部分的 php 程序員。一些常規的名詞(比如參數、函數、返回值)和一些通用的語法(比如 `if else`、`for 循環`等)不再任何說明和解釋,大家自行搜索即可。 我希望我的這個系列的博客能幫大家對 C 語言基礎做到一個穿針引線的作用,讓大家能夠上手 C 語言的開發,比如 php 程序員開發 php 擴展。 # 實驗 新建文件`test1.c` ```c #include <stdio.h> int main(int argc, char const *argv[]) { printf("%s\n", "1111"); return 0; } ``` # 編譯 ```c zhoumengkang@bogon:~/Downloads$ gcc test1.c -o test1 ``` # 執行 ```javascript zhoumengkang@bogon:~/Downloads$ ./test1 1111 ``` # 總結 我們從上往下看,有兩個知識點需要學習。 ## 頭文件 我們發現我們在最開始使用了`#include <stdio.h>`這個文件,這是因為我們在使用的`printf`函數是在`stdio.h`里面定義的。我們可以通過 ```sh man 3 printf ``` 來查閱 ```sh PRINTF(3) Linux Programmer's Manual PRINTF(3) NAME printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf - formatted output conversion SYNOPSIS #include <stdio.h> int printf(const char *format, ...); int fprintf(FILE *stream, const char *format, ...); int sprintf(char *str, const char *format, ...); int snprintf(char *str, size_t size, const char *format, ...); ``` 如上所示,也就是說在使用這四個打印函數的時候都需要包含`<stdio.h>`。 ### 認識 man 命令 順便說下為什么是`man 3`,因為`man`查看手冊的時候是分章節的,章節列表 章節編號|章節名稱|章節主要內容 -----|----|---- 1|General Commands|用戶在shell中可以操作的指令或者可執行文檔 2|System Calls|系統調用的函數與工具等 3|Sunroutines|C語言庫函數 4|Special Files|設備或者特殊文件 5|File Formats|文件格式與規則 6|Games|游戲及其他 7|Macros and Conventions|表示宏、包及其他雜項 8|Maintenence Commands|表示系統管理員相關的命令 如果我輸入的是 ```sh man printf ``` 出來的結果和`man 1 printf`一樣,查的是 shell 命令里面的`printf` ``` PRINTF(1) User Commands PRINTF(1) NAME printf - format and print data SYNOPSIS printf FORMAT [ARGUMENT]... printf OPTION ... ``` man 是按照手冊的章節號的順序進行搜索的,所以我們在查C語言庫函數的時候,記得使用`man 3 xxx` ## main 函數 main 函數是整個程序的入口,所以編譯一個項目,main 函數有且僅有有幾個。 > https://www.zhihu.com/question/28360770 > main函數就是這個約定好的用戶代碼默認入口。 > 當然,只要你愿意,改成啥都行。比如你改成nomain,那么編譯鏈接時就要指定入口了(同時指定不鏈接CRT的入口代碼)。 ```c #include <stdio.h> #include <stdlib.h> int nomain(int argc, char const *argv[]) { printf("%s\n", "1111"); exit(0); } ``` ```sh gcc xxx.c -e nomain -nostartfiles ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看