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++] char array initialization problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon Aug 11, 2008 1:59 pm    Post subject: [C++] char array initialization problem Reply with quote

Hey,

I'm trying to in this array:
Code:
char loginpacket_end[23] = { 0x00, 0x2B, 0x21, 0x5A, 0x22, 0x58, 0xF2, 0xE0, 0x0E, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x3C, 0xD4 , 0x00 , 0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00 };


Compiler says:
Code:
c:\dokumente und einstellungen\reakw0n\eigene dateien\visual studio 2008\projects\rnd\rnd\main.cpp(102) : warning C4309: 'initialization': Shorted a constant value
c:\dokumente und einstellungen\reakw0n\eigene dateien\visual studio 2008\projects\rnd\rnd\main.cpp(102) : warning C4309: 'initialization': Shorted a constant value
c:\dokumente und einstellungen\reakw0n\eigene dateien\visual studio 2008\projects\rnd\rnd\main.cpp(102) : warning C4309: 'initialization': Shorted a constant value
c:\dokumente und einstellungen\reakw0n\eigene dateien\visual studio 2008\projects\rnd\rnd\main.cpp(102) : warning C4309: 'initialization': Shorted a constant value

(translated)

And line 102 is for sure the array line, and also when I send the packet it's sending like nothing.

I asked Lurc about that and he threw this line in a project and it compiled fine. What's the problem there?
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Mon Aug 11, 2008 2:27 pm    Post subject: Reply with quote

Code:
   char loginpacket_end[24] = "\x00\x2B\x21\x5A\x22\x58\xF2\xE0\x0E\xB4\x00\x00\x00\x00\x3C\xD4\x00\x00\x00\x00\x02\x00\x00";

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

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon Aug 11, 2008 3:12 pm    Post subject: Reply with quote

Thanks!
But can you explain why my array doesn't work?

Edit: When I do printf with that it doesn't print anything... Confused
Back to top
View user's profile Send private message
Cx
Master Cheater
Reputation: 0

Joined: 27 Jul 2007
Posts: 367

PostPosted: Mon Aug 11, 2008 3:32 pm    Post subject: Reply with quote

The first char null terminates it...
_________________

armed with this small butterfly net
i will face the world alone
& never be lonely.
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon Aug 11, 2008 4:16 pm    Post subject: Reply with quote

Ohwell yea Cx.
The problem was I used a STRING and merged all arrays witht he += operator, but it didn't terminate on 0x00, it just ignored it.
Now I'm using sprintf_s().

But when I send the packet, I need to get the length of the char-array. But since strlen() ignores 0x00, what should I use instead of it?

Edit: Okay got it :>

Thanks everyone.
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