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 


Pointer Issue c++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Varreon
Advanced Cheater
Reputation: 0

Joined: 13 Jun 2007
Posts: 80

PostPosted: Tue Jul 10, 2007 10:32 am    Post subject: Pointer Issue c++ Reply with quote

Im writing up a macro program for rs and i started with the ui and the recording of points. I declared:

POINT *inv[29]; //to hold each inv slot point and rather than me reference inv[0], i made the array larger.

int cur=1; //for tracking through recording.

THen to record the points I have this:
if (setup==true & table->vkCode==162){
// ShowMessage(cur);
GetCursorPos(inv[cur]);
cur++;

up to here it works fine.


Then to play them back, I get an access error. Im not very knowledgeable on pointers, maybe you guys can help:

POINT *p = inv[cur];
SetCursorPos(p->x,p->y);
cur++;



error.GIF
 Description:
 Filesize:  97.05 KB
 Viewed:  4491 Time(s)

error.GIF



_________________
Back to top
View user's profile Send private message
TheSorc3r3r
I post too much
Reputation: 0

Joined: 06 Sep 2006
Posts: 2404

PostPosted: Tue Jul 10, 2007 1:31 pm    Post subject: Reply with quote

I don't see the need for a pointer at all in this situation, but if you insist..

Is inv allocated memory at that point in execution? It appears to be a global variable and you can easily go wrong with those..

_________________


Don't laugh, I'm still learning photoshop!
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Tue Jul 10, 2007 1:36 pm    Post subject: Reply with quote

sorcerer,

when you do

Code:

char array[260];


260 chars are allocated for you.
Back to top
View user's profile Send private message
Varreon
Advanced Cheater
Reputation: 0

Joined: 13 Jun 2007
Posts: 80

PostPosted: Tue Jul 10, 2007 2:39 pm    Post subject: Reply with quote

id rather not use pointers, but GetCursorPos requires one. If theres a way around this, id be glad to know.
_________________
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Tue Jul 10, 2007 2:42 pm    Post subject: Reply with quote

No it doesn't. It accepts two integers.
Back to top
View user's profile Send private message
Varreon
Advanced Cheater
Reputation: 0

Joined: 13 Jun 2007
Posts: 80

PostPosted: Tue Jul 10, 2007 8:48 pm    Post subject: Reply with quote

im using bcb. It sais that it requires a pointer to a point. I tried giving it two integers, but it sais that it is two few parameters.
_________________
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25814
Location: The netherlands

PostPosted: Wed Jul 11, 2007 5:17 am    Post subject: Reply with quote

p->x and p->y are also just 2 integers (dereferenced from the p object)

so why wouldn't SetCursorPos(0,0) work?

or
int x,y;
SetCursorPos(x,y);

and if it REALLY needs a pointer and not a point then

SetCursorPos(&x,&y);

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Varreon
Advanced Cheater
Reputation: 0

Joined: 13 Jun 2007
Posts: 80

PostPosted: Wed Jul 11, 2007 10:30 am    Post subject: Reply with quote

SetCursorPos takes two integers, but GetCursorPos takes a pointer to a point.
I recently figured out that in getcursorpos, i could do &inv, and not declare it a pointer at all.

_________________
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