iOS 學習筆記:(二)C語言 —— 2.1 編寫、編譯、連結和執行

來源:互聯網
上載者:User

iOS 學習筆記:(二)C語言 —— 2.1 編寫、編譯、連結和執行

#include <stdio.h>int main () {printf("*\n**\n***\n****\n");printf("*****\n");return 0;}//------------1. 編寫.c源檔案2. 編譯.c源檔案為.o目標檔案3. 連結4. 運行// 下面是編譯過程cd Users/manoel/Desktop/0706ls -lcc -c Review.c// 沒提示資訊,說明編譯成功。// 下面是連結過程cc Review.o// 下面是運行.o檔案的過程./Review.out// 輸出結果**********終端裡面的指令,產生的檔案或檔案夾,都是在當前檔案夾下面。main是程式的入口函數。int sgw() {printf("*\n**\n***\n****\n");printf("*****\n");return 0;}編譯時間,只檢測文法,並不會檢測有沒有man函數。就算沒有main函數,也不會報錯。連結時,會報錯。Undefined symbols for architecture x86_64:  "_main", referenced from:錯誤描述:因為沒有主函數// 函數調用函數#include <stdio.h>int test () {printf("*\n**\n***\n****\n");printf("*****\n");return 0;}int main () {test();return 0;}cc Review.c會執行編譯和連結兩個操作。// 下面的程式可以編譯成功,但是無法連結和運行。int main () {test();return 0;}自己發現的問題:為什麼每次gcc編譯後產生的都是a.out?可以設定輸出檔案的名字gcc -o b.out a.c則設定編譯後的檔案名稱字為b.out使用gcc的協助多看看吧。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.