如何將程式打包成exe檔案
阿新 • • 發佈:2018-11-20
下面以一個簡單的遊戲程式碼對其打包
- 程式碼如下
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
int main()
{
int a, b;
srand(time(NULL));
a = 1 + (rand() % 100);
/printf("%d", a);/
while (a)
{
printf(“please input the number you think\n”);
scanf("%d", &b);
if (a == b)
{
printf(“congratulations,what you guess is right\n”);
break;
}
if (b > a)
printf(“what you guess is bigger than the rirht one\n”);
if (b < a)
printf(“what you guess is smaller than the rirht one\n”);
}
getchar();
getchar();
return 0;
}
操作流程圖如下
- 在選單欄裡面會看到
DEBUG
這個標誌,點選它選擇裡面的release
(漢語意思釋出) - 在視圖裡面找到
解決方案資源管理器
,點開它然後右鍵你的檔名選擇屬性
,開啟後在配置屬性
裡找到C/C++
點開後選擇程式碼生成
,在右邊點開執行庫裡面的選擇多執行緒(/MT)
最後點選確定
, - 在視圖裡面找到
解決方案資源管理器
,點開它然後右鍵你的標頭檔案
——新增
(滑鼠在新增一欄平行移到右邊會發現)—資源
(點選資源),這時會出現新增資源
的視窗,選擇Icon
右邊選擇匯入
(執行這步的前提首先先在網上下一個Icon型別的圖示網址如下)在裡面將你下載的圖示貼上到裡面並選擇它開啟
https://www.easyicon.net/ - 在選單欄裡面點開
生成
選擇重新生成解決方案
. - 在視圖裡面找到
解決方案資源管理器
,點開它然後右鍵你的檔名選擇檔案資源管理器
,這是你開啟的可能是最裡面的資料夾,在視窗上面的路徑中選擇該資料夾的上一欄,你會看到release資料夾
,點開它會發現帶圖示的exe
檔案,這樣就可以把這個小程式傳給你的小夥伴了。