View previous topic :: View next topic |
Author |
Message |
educofu Expert Cheater
Reputation: 3
Joined: 21 Aug 2009 Posts: 171 Location: Brazil,MG,OP
|
Posted: Wed Jan 19, 2011 10:58 am Post subject: [C++] Function that store value in the desired variable |
|
|
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 |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Jan 19, 2011 11:00 am Post subject: |
|
|
pointers
|
|
Back to top |
|
 |
educofu Expert Cheater
Reputation: 3
Joined: 21 Aug 2009 Posts: 171 Location: Brazil,MG,OP
|
Posted: Wed Jan 19, 2011 11:02 am Post subject: |
|
|
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 |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Jan 19, 2011 11:07 am Post subject: |
|
|
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 |
|
 |
educofu Expert Cheater
Reputation: 3
Joined: 21 Aug 2009 Posts: 171 Location: Brazil,MG,OP
|
Posted: Wed Jan 19, 2011 11:28 am Post subject: |
|
|
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 |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Jan 19, 2011 12:01 pm Post subject: |
|
|
void ReadString(int address,int size, char* coolstring);
|
|
Back to top |
|
 |
|