ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hey,
I'm currently having a similar problem. If you want to split your string up you have to memcpy (string.h) this string to a character array first, that is of course if this string is initialized by a pointer (as char *pointertostring).
An example. You have the array char txt[5] and the string char *original_text, which is equal to "Hello". If you memcpy(&txt, original_text, 7); then "H" would be txt[0]m "e" txt[1] and so on. Keep in mind that each string is terminated by a null character ("\0"), so you have to copy to more elements than your string is long...
Once you've done this you can analyze your string piece by ptece or rather element by element.
However, and this is where I am stuck at... , most functions expect the "char *pointertostring", thus a constant, as an argument.
Let's say that I have the values "192.168.0.1" stored in an array and need to make a constatant out of it to send it to inet_ntoa. Does anybody know how I can do this (parse it perhaps..didn't work though)?
I guess none realised that "Lua" is a programming language. You should make it clear in your first post, not just putting mysterious 'Lua' in the heading.
I have no idea how popular it is. But I guess Lua is likely a language popularly used for teaching purpose. (Modula-2 and Haskell are languages of this category too)
I am afriad I am helping you to do your homework...
The less people use it, the less likely you can get help form LQ. You may be better off using Lua mailing.list. But then the lecturers are watching :-)
Always check the documentation. It takes me just a few min to find out:
Lua scripting is used in custom WoW interfaces, and many other things. I didn't realize before WoW, but it is actually used in quite a number of applications, and they have a C library that lets you add lua scripting functionality to your own applications.
I've just started looking at it a bit myself, but you might want to take a look at the string handling functions of Lua 5.0 here. (the version used by WoW, if that is what you are using Lua for)
ahwkong
Sorry but this is not a homework my friend is running a server, and he asked me if there was a command in the server which list's all registered users (since there are both unregistered and registered)
But since there aren't any, i told him i would create a script that does the trick
the Server supports Lua so i decided to give it a chance
thanks for the help man, i am now trying to see if my modification on that link you gave me will work
Interresting .
Let's revert to C++ . Since my question is similar, though apparently in a different language, I will not start a seperate thread but simply refrase my prior question:
I have a character array (constant), which needs to be casted into whatever char *pointerToString represents. Usually this would be the address of the first item of a character array named pointerToString.
The problem is that no function (particullarly inet_ntoa) accepts a character array, even if I present it with a pointer to the first item. So, how do I get arround this problem?
Originally posted by ahwkong I revisted the web site after your post, and find that there are many project makes use of Lua (http://www.lua.org/uses.html). Impressive.
I had jumped too quickly into conclusion about the domain of Lua previously.
I also was impressed that so many things made use of Lua, some of them quite familiar like Baldur's Gate. I was suprised that I had never heard about it before.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.