edited 1×, last 26.01.11 02:45:23 am
Forum
![>](img/i_next.png)
![>](img/icons/cs2d.png)
![>](img/i_next.png)
![>](img/i_next.png)
How to iterate a table from C/C++
2 replies![To the start](img/i_first.png)
![Previous](img/i_prev.png)
![Next](img/i_next.png)
![To the start](img/i_last.png)
1
2
3
4
5
6
7
2
3
4
5
6
7
lua_pushnil(L); //This will be the key while(lua_next(L,YOURINDEX) !=0) { 	int k = lua_tointeger(L,-2); //Get the key 	int v = lua_tointeger(L,-1); //Get the value 	lua_pop(L,1); //Pop v from the stack and keep k for the next iteration (as we did when we pushed nil) }
![To the start](img/i_first.png)
![Previous](img/i_prev.png)
![Next](img/i_next.png)
![To the start](img/i_last.png)