g++
GNU C++ Compiler ( g++ ) เป็นคอมไพเลอร์ใน Linux ซึ่งใช้ในการคอมไพล์โปรแกรม C++ มันรวบรวมทั้งไฟล์ที่มีนามสกุล .c และ .cpp เป็นไฟล์ C++
ต่อไปนี้เป็นคำสั่งคอมไพเลอร์เพื่อคอมไพล์โปรแกรม C++
g++ program.cpp -o filename
ที่นี่
ชื่อไฟล์ − ชื่อไฟล์ที่มีนามสกุล .c หรือ .cpp
ต่อไปนี้เป็นตัวอย่างการใช้คอมไพเลอร์ g++
ตัวอย่าง
#include <iostream>
using namespace std;
int main() {
int a = 20;
cout << "The value of a : " << a;
return 0;
} ผลลัพธ์
$g++ -o main *.cpp $main The value of a : 20
gcc
GNU C Compiler ( gcc ) เป็นคอมไพเลอร์ใน Linux ซึ่งใช้ในการคอมไพล์โปรแกรม C มันรวบรวมไฟล์ที่มีนามสกุล “.c”.
ต่อไปนี้เป็นคำสั่งคอมไพเลอร์เพื่อคอมไพล์โปรแกรมภาษาซี
gcc program.c -o filename
ที่นี่
ชื่อไฟล์ − ชื่อไฟล์ที่มีนามสกุล .c
ต่อไปนี้เป็นตัวอย่างการใช้คอมไพเลอร์ gcc
ตัวอย่าง
#include <stdio.h>
int main() {
int a = 20;
printf("The value of a : %d", a);
return 0;
} ผลลัพธ์
$gcc -o main *.c $main The value of a : 20