MinGW : Hello World C/C++ (Windown10)
ชลิตา จูมสีมา : เขียน
หลังจากติดตั้ง MinGW เราสามารถทดสอบการทำงานแล้วรันได้ดังนี้
ภาษา C ไฟล์ main.c
#include <stdio.h>
void main(){
printf("Hello World");
getchar();
}
ทดสอบด้วยคำสั่ง gcc main.c -o main.exe
--------------------------------------
ภาษา C++ ไฟล์ main.cpp
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for (const string& word : msg){
cout << word << " ";
}
cout << endl;
}
ทดสอบด้วยคำสั่ง (ไม่จำเป็นต้องใส่ .exe) gcc main.cpp -lstdc++ -o main.exe
..
ความคิดเห็น
แสดงความคิดเห็น