Try   HackMD

IDE 編譯器介紹與安裝

什麼是編譯器/直譯器?

先講講編譯是什麼:

首先我們要先知道低階語言高階語言的區別:

  • 低階語言:電腦看得懂的 如:0、1
  • 高階語言:我們人類看得懂的 如:C、C++、Python、Java

因為電腦只看得懂0、1。
所以當我們寫好一個程式碼的時候,就需要一個翻譯官將我們的語言轉換成0、1,好讓電腦讀得懂我們要幹嘛,並且執行動作。

翻譯官將我們寫的程式翻譯成電腦看得懂的語言時,這個過程就叫編譯
理所當然,翻譯官的身分就是編譯器

C/C++ 常用的編譯器為MinGW


編譯器和直譯器的差別

兩個都是扮演翻譯官的角色,那有甚麼區別?

  • 編譯器: 必須全部寫完之後,再一次全部翻譯,才可以執行。 如:C、C++、Java。
  • 直議器: 一行一行直接翻譯,每翻譯一行程式敘述就立刻執行,然後再翻譯下一行,再執行,所以直譯器可即時翻譯、執行。 如:Python、JavaScript[1].。

以C和Python舉例:

這是C語言

#include<stdio.h> int main(){ int a=10; int b=10; printf("%d",a); print(a); printf("%d",b); }

執行結果:

a.cpp: In function 'int main()':
a.cpp:6:12: error: 'print' was not declared in this scope
     print(a);
            ^

這是Python

a=10 b=10 print(a) printf(a) print(b)

執行結果:

10
Traceback (most recent call last):
  File "d:\學習\C++\主要作答區\text.py", line 4, in <module>
    printf(a)
NameError: name 'printf' is not defined

C/C++有甚麼IDE/編輯器可以用?

IDE:中文為整合開發環境,IDE通常包含程式語言編輯器、自動構建工具(編譯器)、通常還包括除錯器

Codeblocks

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

APCS的給的編譯器是Codeblocks
學校的編譯器也是Codeblocks
比賽也可以用Codeblocks
所以沒有不用Cdoeblocks的道理。

等等會教下載


DevC++

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

DevC++ 是很多人剛入門程式語言的時候會接觸到的IDE,畫面簡單,還有中文翻譯,對新手來說很友善,但它太久沒更新了,一些較新的語法並沒有支援,所以某些人會很不喜歡用 DevC++

載點


vim

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

很屌,可是前提是要學Linux的指令,是一個很大的坑。


-編輯器分隔線

以下剛下載的時候都只是文字編輯器,需要另外安裝編譯器和設定才能編譯C/C++
但好處是體積輕巧,啟動快速。

VSCode

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

VScode 是非常好用的一個文字編輯器,支援各種插建,可以透過插建編譯多種程式語言,還可以改變VScode的背景讓你感覺很舒服。很好玩OUO

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

這是我的VScode

載點


Sublime Text

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

跟VScode差不多,也有很多的套件可以使用,只是功能似乎沒比VScode還豐富。但已編輯器來說已經很足夠了

載點


Codeblocks編譯器安裝教學

  1. 點Codeblocks官網

  2. 點右邊的Download

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  3. 點 Download the binary release

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  4. 往下滑一點找到Microsoft Windows,找到codeblocks-20.03mingw-setup.exe,點右邊的Sourceforge . net

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  5. 接下來他就會幫你自動下載,然後一直按下一步就好

Codeclocks基本使用

進去的畫面

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • ctrl+shift+n 可以直接叫出空白的工作畫面就可以直接使用
  • ctrl+s可以存檔案
  • 按F9可以編譯+執行
tags: 中和高中

  1. Java、JavaScipt兩個是不一樣的東西,至於差在哪,我也不太熟,https://kknews.cc/zh-tw/tech/aerxrm6.html ↩︎