Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] Function that store value in the desired variable

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
educofu
Expert Cheater
Reputation: 3

Joined: 21 Aug 2009
Posts: 171
Location: Brazil,MG,OP

PostPosted: Wed Jan 19, 2011 10:58 am    Post subject: [C++] Function that store value in the desired variable Reply with quote

hi all--

im trying to create a function to read a string and then store it in the desired variable.

i have this function:

Code:


char   ReadStringValue[512];

void ReadString(int address,int size)
{
    int offset=0;
    while(offset!=size)
    {
         ReadStringValue[offset]=Read(address+offset,1);
         offset++;
         }
    }


that will store the string into ReadStringValue, but i wanted to do that to saving the string in any array.

it should be like that:

void ReadString(int address,int size, "where to save string")

and "where to save string" should now have the string.

any help?

*note: that function is using another function i created:
Read(address,size) wich return the value (in 1,2 or 4 bits(size)) in address of a previously opened process.

_________________
"I finally started thinking outside of the box, only to find myself in a larger box."


Last edited by educofu on Wed Jan 19, 2011 11:01 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Jan 19, 2011 11:00 am    Post subject: Reply with quote

pointers
Back to top
View user's profile Send private message
educofu
Expert Cheater
Reputation: 3

Joined: 21 Aug 2009
Posts: 171
Location: Brazil,MG,OP

PostPosted: Wed Jan 19, 2011 11:02 am    Post subject: Reply with quote

an example plz? -- i know the basics of pointer, but not sure how to use that in functions like that.
_________________
"I finally started thinking outside of the box, only to find myself in a larger box."
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Jan 19, 2011 11:07 am    Post subject: Reply with quote

http://www.cplusplus.com/doc/tutorial/pointers/

also you can probably just dumb everything down to one generic function.


"where to save string" can just be a pointer to your buffer.
also std::string would probably make your life easier and solve a lot of problems automatically
Back to top
View user's profile Send private message
educofu
Expert Cheater
Reputation: 3

Joined: 21 Aug 2009
Posts: 171
Location: Brazil,MG,OP

PostPosted: Wed Jan 19, 2011 11:28 am    Post subject: Reply with quote

already read that slovach, great tuto indeed.

i just need 1 example!

_________________
"I finally started thinking outside of the box, only to find myself in a larger box."
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Jan 19, 2011 12:01 pm    Post subject: Reply with quote

void ReadString(int address,int size, char* coolstring);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites