• Steam recently changed the default privacy settings for all users. This may impact tracking. Ensure your profile has the correct settings by following the guide on our forums.

C++ help

footballs99

New Member
hello,

iam newbie in psp c++ programming

i can do some progs on lua

but i need to do that in c++

so,

is there any c++ alternate to this lua script
[highlight=lua]white = Color.new(255,255,255)

file = io.open("flash0:/vsh/etc/version.txt","r")
mystring = file:read()
file:close()

newstring = string.sub(mystring,9,12)

screen:clear(white)
screen:print(1,1,"Your version.txt version is: "..newstring)
screen.flip()
screen.waitVblankStart()
end[/highlight]

thanks
 
Of course there is an alternative because the Lua interpreter is written in C/C++. Nobody is going to code it for you, however. You're going to need to figure it out for yourself.
 
Of course there is an alternative because the Lua interpreter is written in C/C++. Nobody is going to code it for you, however. You're going to need to figure it out for yourself.
I agree. If you are learning C/++ you should be able to figure it out since most of that code is self explanatory

Copy and pasting code is not learning, so if you don't understand whats happening in your LUA program you won't be able to translate it to C/++

If there is a certain part you want to understand more than we can help you with that, but we are not going to just give you the code
 
well, I know that trying to make a C/C++ version of string.sub is a bitch, so here's one I made a couple of months ago:
Code:
void strsub(char *src, int start, int lenght)
{
	char *out = (char*)malloc(sizeof(char)*lenght);
	memcpy(out, (src+start), lenght);
	memset(src, 0, strlen(src));
	memcpy(src, out, strlen(out));
	free(out);
}
But you'll have to figure the IO operations yourself out ;)
 
well, I know that trying to make a C/C++ version of string.sub is a bitch, so here's one I made a couple of months ago:
Code:
void strsub(char *src, int start, int lenght)
{
	char *out = (char*)malloc(sizeof(char)*lenght);
	memcpy(out, (src+start), lenght);
	memset(src, 0, strlen(src));
	memcpy(src, out, strlen(out));
	free(out);
}
But you'll have to figure the IO operations yourself out ;)

You can simply do a pointer/array copy.
Something like:
for ( int i = 0; i < length; ++i ) { src = src[start+i] }; src[length] = 0;
 
Back
Top