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 


From char to int?

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

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Mon May 14, 2007 12:54 pm    Post subject: From char to int? Reply with quote

I'm not sure I have to convert char to int but heres my problem:

I'm trying to compile this code
Code:
         
// other code up here...
         char XCOORD[1024];
         char YCOORD[1024];
         GetDlgItemText (Hwnd,IDC_XC, XCOORD, 1024);
         GetDlgItemText (Hwnd,IDC_YC, YCOORD, 1024);


TextOut(Screen, XCOORD, YCOORD, mytextbuffer, lstrlen(mytextbuffer));


unfortunately I get this error:
Quote:
'TextOutA' : cannot convert parameter 2 from 'char [1024]' to 'int'


After looking for TextOut on MSDN, TextOut syntax is
Code:
 BOOL TextOut(
  HDC hdc,           // handle to DC
  int nXStart,       // x-coordinate of starting position
  int nYStart,       // y-coordinate of starting position
  LPCTSTR lpString,  // character string
  int cbString       // number of characters
);


The X and Y are in "int" therefor my char buffer doesn't work. Mad

Can you guys help me fix this problem?

EDIT: tried atoi(&XCOORD); and reinterpret_cast with no success

_________________
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Mon May 14, 2007 1:21 pm    Post subject: Reply with quote

You have to use atoi() on each item in the array individually. Then add them all together while multiplying each number by a power of 10 to keep it in its correct spot. Optimize it yourself, I also haven't tested it so there is bound to be errors.

Edit: Cut the code, after I went over it I decided it was too ugly to let out into the world.


Last edited by Flyte on Mon May 14, 2007 4:03 pm; edited 1 time in total
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Mon May 14, 2007 2:25 pm    Post subject: Reply with quote

Are XCOORD & YCOORD ever going to contain a character? (I dont see why co-ordinates would)

If not, just make them integers.
Back to top
View user's profile Send private message MSN Messenger
UnLmtD
Grandmaster Cheater
Reputation: 0

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Mon May 14, 2007 2:36 pm    Post subject: Reply with quote

Thanks for your answer Flyte. Noz thanks, your right they won't contain any characters Embarassed
_________________
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Mon May 14, 2007 3:22 pm    Post subject: Reply with quote

I suppose if you really want them to be char's try:
Code:

TextOut(Screen, (int)XCOORD, (int)YCOORD, mytextbuffer, lstrlen(mytextbuffer));
Back to top
View user's profile Send private message MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Mon May 14, 2007 4:06 pm    Post subject: Reply with quote

noz3001 wrote:
I suppose if you really want them to be char's try:
Code:

TextOut(Screen, (int)XCOORD, (int)YCOORD, mytextbuffer, lstrlen(mytextbuffer));


That would just give the ascii value of the number, not the number itself.

For example:

1 in ascii is 49.
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Mon May 14, 2007 4:56 pm    Post subject: Reply with quote

IF YOU ARE USING A LOT OF REINTERPRET CASTS YOU ARE DOING SOMETHING WRONG
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