自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

解析Lua解釋器運(yùn)行方法學(xué)習(xí)教程

移動(dòng)開發(fā) iOS
Lua解釋器運(yùn)行方法學(xué)習(xí)教程是本文要介紹的內(nèi)容,主要是來了解LUA解釋器的使用方法,關(guān)于解釋器如何來運(yùn)行,那么一起來看內(nèi)容詳解。

Lua解釋器運(yùn)行方法學(xué)習(xí)教程是本文要介紹的內(nèi)容,主要是來了解LUA解釋器的使用方法,關(guān)于解釋器如何來運(yùn)行,那么一起來看內(nèi)容詳解。

1、直接運(yùn)行l(wèi)ua.exe,輸入lua語句,比如print("hello world")

2、將print("hello world")寫進(jìn)一個(gè)名為hello.lua的文件里,假設(shè)放在D盤,然后可以打開lua.exe后運(yùn)行dofile("d:/hello.lua")--(之前寫成了DoFile,事實(shí)證明得小寫的dofile),lua解釋器就會(huì)執(zhí)行這個(gè)文件內(nèi)的指令。

3、使用命令提示符,即直接運(yùn)行cmd

  1. D:\LUA>lua hello.lua  
  2. hello world  
  3.  
  4. D:\>lua  
  5. > print("hello")  
  6. hello  
  7.  
  8. D:\>lua d:/lua/hello.lua  
  9. hello world 

簡易解釋器代碼(C++)

  1. #include <stdio.h> 
  2. #include <string.h> 
  3. #include "lua.hpp"  
  4. #include "luaconf.h"  
  5.  
  6. int main (void)  
  7. {  
  8.  char buff[256];  
  9.  int error;  
  10.  
  11.  lua_State *L = lua_open();   
  12.  
  13.  luaopen_base(L);     
  14.  luaopen_table(L);     
  15.  
  16.  luaopen_string(L);     
  17.  luaopen_math(L);     
  18.  
  19.  while (fgets(buff, sizeof(buff), stdin) != NULL)  
  20.  {  
  21.   error = luaL_loadbuffer(L, buff, strlen(buff), "line") || lua_pcall(L, 0, 0, 0);  
  22.   if (error)  
  23.   {  
  24.    fprintf(stderr, "%s", lua_tostring(L, -1));  
  25.    lua_pop(L, 1);  
  26.   }  
  27.  }  
  28.  
  29.  lua_close(L);  
  30.  return 0;  

小結(jié):解析Lua解釋器運(yùn)行方法學(xué)習(xí)教程的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-08-23 15:57:21

Lua元表元方法

2011-08-24 15:22:09

2011-08-24 09:49:38

VS2008Lua解釋器

2011-08-25 16:38:06

EditPluslua

2011-08-24 11:08:09

Lua

2011-08-31 17:35:18

Lua解釋器Script.NET

2009-12-03 09:59:34

2011-08-23 16:48:41

Lua 5.1API 函數(shù)

2009-08-27 09:27:49

C#擴(kuò)展方法

2009-08-31 16:51:11

C# Main()方法

2011-08-23 13:27:46

Luaglobal變量

2009-08-21 18:01:32

C#匿名方法

2009-08-12 17:32:44

C#反射方法

2009-08-14 17:38:08

C#改寫方法

2011-08-23 17:11:13

Lua事件C#

2011-08-25 13:44:11

LUA下載SciTE

2011-08-24 15:28:02

Lua編譯器解釋器

2011-08-29 18:09:45

LUAWeb開發(fā)服務(wù)器

2009-12-14 14:01:29

Linux學(xué)習(xí)方法

2011-08-24 11:03:33

LUA環(huán)境 安裝
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號