An online game gave me a question and asked me to write a fuzzy parameter for Lua. It is very useful, because the functions of C and Lua functions are unifiedProgramMember programming is very advantageous.
The function parameters are variable. Some people may not be clear about this function, but they are still using it without being clear about it. There is such a chapter in program Lua. It is not provided here. Now let's talk about how C ++ is vague.
All of them use the sprintf () function. Some people may be familiar with C ++ and may have never used the sprintf () function. Here is a small example to recall the C scenario.
CPP file: Main. cpp
--------------------------------------------------------------------------
# Include <iostream>
Using namespace STD;
Int main ()
{
Char buffer [100];
Int I = 5;
Char * STR = "Lua Script Programming! ";
Sprintf (buffer, "% S | % d", STR, I );
Cout <buffer <Endl;
Return 0;
}
----------------------------------------------------------------------------
Output: -- Lua Script Programming! | 5
This example is very simple. I have learned nothing about C.
The problem is that the sprintf () function parameter is not fixed. Now we need to implement a function like sprintf, which is very convenient to use. Tsfont engines in tsengine all use fuzzy functions to output text. In the nehe tutorial, such functions are displayed. I am just a shift. However, nehe only gave this question. In fact, fuzzy functions are more than just usable.
The following example shows how to write a fuzzy function to collaborate with a Lua fuzzy function.
CodeIt is easy to use.
----------------------------------------------------------------------------
# Include "lua_fun.h"
Lua_state * l;
Int main (void)
{
L = lua_open ();
Lual_openlibs (L );
Lual_loadfile (L, "luatext. Lua ");
Lua_pcall (L, 0, 0, 0 );
//////////////////////////////////////// ///////////////////////////////////////
// Note: | function | (...) argument | endflag
Cout <multiform ("multiform",-20, lua_multfun_end) <Endl;
//////////////////////////////////////// ///////////////////////////////////////
Lua_close (L );
Getchar ();
Return 0;
}
----------------------------------------------------------------------------
Nano ROBOT: Demo download
Http://www.namipan.com/d/2696cb127665a4306f22f7f6cab51a2e422c2568a1160000