大家熟知的易語言底層其實(shí)就是c語言來實(shí)現(xiàn)的,c語言的32個(gè)關(guān)鍵字加上一些常用的其他,使用#define這種宏定義來實(shí)現(xiàn)簡(jiǎn)單的漢語替換
1.下面就先打開VisualStudio,在頭文件目錄下新建一個(gè) 標(biāo)識(shí)符.h 的文件,開始宏定義封裝我們的易語言
//auto 局部變量(自動(dòng)儲(chǔ)存)#define 自動(dòng) auto//break無條件退出程序最內(nèi)層循環(huán)#define 中斷 break //case switch語句中選擇項(xiàng)#define 情況 case//char單字節(jié)整型數(shù)據(jù)#define 字符 char//const定義不可更改的常量值#define 常量 const//continue中斷本次循環(huán),并轉(zhuǎn)向下一次循環(huán)#define 繼續(xù) continue//default switch語句中的默認(rèn)選擇項(xiàng)#define 默認(rèn) default//do 用于構(gòu)成do.....while循環(huán)語句#define 執(zhí)行 do//double定義雙精度浮點(diǎn)型數(shù)據(jù)#define 雙精度 double//else構(gòu)成if.....else選擇程序結(jié)構(gòu)#define 否則 else//enum枚舉#define 枚舉 enum//extern在其它程序模塊中說明了全局變量#define 外部變量 extern//float定義單精度浮點(diǎn)型數(shù)據(jù)#define 單精度 float//for構(gòu)成for循環(huán)語句#define 循環(huán) for//goto構(gòu)成goto轉(zhuǎn)移結(jié)構(gòu)#define 跳轉(zhuǎn) goto//if構(gòu)成if....else選擇結(jié)構(gòu)#define 如果 if//int基本整型數(shù)據(jù)#define 整數(shù) int//long長(zhǎng)整型數(shù)據(jù)#define 長(zhǎng)整型 long//registerCPU內(nèi)部寄存的變量#define 寄存變量 register//return用于返回函數(shù)的返回值#define 返回 return//short短整型數(shù)據(jù)#define 短整型 short//signed有符號(hào)數(shù)#define 有符號(hào) signed//sizoef計(jì)算表達(dá)式或數(shù)據(jù)類型的占用字節(jié)數(shù)#define 求大小 sizeof//static定義靜態(tài)變量#define 靜態(tài) static//struct定義結(jié)構(gòu)類型數(shù)據(jù)#define 結(jié)構(gòu)體 struct//switch構(gòu)成switch選擇結(jié)構(gòu)#define 選擇 switch//typedef重新定義數(shù)據(jù)類型#define 重新定義 typedef//union聯(lián)合類型數(shù)據(jù)#define 聯(lián)合體 union//unsigned定義無符號(hào)數(shù)據(jù)#define 無符號(hào) unsigned//void定義無類型數(shù)據(jù)#define 空 void//volatile該變量在程序中執(zhí)行中可被隱含地改變#define 隱藏變量 volatile//while用于構(gòu)成do...while或while循環(huán)結(jié)構(gòu)#define 當(dāng) while#define 主函數(shù) main#include<stdlib.h>void notepad(){ system("notepad");}#define 記事本 notepad()void calc(){ system("calc");}#define 計(jì)算器 calc();void tasklist(){ system("tasklist");}#define 進(jìn)程管理 tasklist(); #define 等待 getchar();void ipconfig(){ system("ipconfig");}#define IP查看器 ipconfig();#include<stdio.h>void hello(){ printf("%s", "hello word");}#define 你好世界 hello();2.在源文件目錄下面新建一個(gè).c文件,引入我們的標(biāo)識(shí)符文件,就可以使用我們的漢語編程了
這里" "和<>的區(qū)別就是一個(gè)引入系統(tǒng)的頭文件,一個(gè)是我們自己的頭文件
#include"elanguage.h" 空 主函數(shù)(){ //計(jì)算器 進(jìn)程管理 IP查看器 你好世界 等待}以上就是相關(guān)的知識(shí)點(diǎn)內(nèi)容,感謝大家對(duì)VEVB武林網(wǎng)的支持。
新聞熱點(diǎn)
疑難解答