Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 16:02

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Int = 4 | Struct int = 8 o.0 ?

Discussion on Int = 4 | Struct int = 8 o.0 ? within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
Terrat's Avatar
 
elite*gold: 130
Join Date: Apr 2012
Posts: 1,173
Received Thanks: 670
Int = 4 | Struct int = 8 o.0 ?

Hallo,
eine kurze Frage die mir gleich mein Kopf zerstört da ich es einfach nicht kapiere.
printf("INT32:%i\n", sizeof(int32_t)); -> Output 4
printf("INT32:%i\n", sizeof(test.type)); -> Output 4 ( struktur = test)
Bis dahin stimmt ja alles lasse ich mir aber das Packet ausgeben nimmt der Integer 8 oder mehr Bytes ein und nicht 4. Woran liegt das ?

Der eigentliche Output sollte so sein:
Code:
4:0 <- byte 
5:0 <- integer 4 bytes
6:0
7:0
8:0
9:1 <- byte
10:3 <- byte
Edit: Es liegt an dem Byte davor in der Struktur wie kann ich den fehler beheben ?
Terrat is offline  
Old 05/24/2015, 14:13   #2
 
suiluJ.'s Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 2,210
Received Thanks: 6,755
#pragma pack(push, 1)
struct foo {
// etc..
};
#pragma pack(pop)
suiluJ. is offline  
Thanks
1 User
Old 05/24/2015, 14:33   #3
 
Terrat's Avatar
 
elite*gold: 130
Join Date: Apr 2012
Posts: 1,173
Received Thanks: 670
Quote:
Originally Posted by Julius... View Post
#pragma pack(push, 1)
struct foo {
// etc..
};
#pragma pack(pop)
Danke hasii <3 ° - °
Terrat is offline  
Reply


Similar Threads Similar Threads
Struct/MAP in struct speichern?
09/19/2013 - C/C++ - 26 Replies
Ich versuche momentan in einer Struct den datentyp map zu speichern, aber sobald ich es in der struct in der headerdatei mit reinpacke stirbt das Programm beim start. sieht ca so aus struct EventGift { DWORD dwID; int nCount; int nPercentage; };
[Collecting] RDB Struct
05/10/2013 - Rappelz Private Server - 7 Replies
hi every one , I have seen a lot of rdb struct but in different topics so i started this topic to collect all of them to help ppl that want to make a rdb tool or anything else and for all of the ppl how have rdb struct in there pc please share it with us :D
[help] new, delete, struct
01/23/2013 - C/C++ - 9 Replies
Well, i have a structure, input and output functions, to get some data, now i would like to make the following: -the user inputs a number (for which i need a dynamic memory reservation) -and that number declares how many times the input should loop) so for example the use puts in 4; it will run the input function 4 times he can tpye in stuff for 4 different companyes or w/e ... same with the output Here is waht i ahev for now:
[c++] struct
08/25/2011 - C/C++ - 2 Replies
Kann closed werden. sry



All times are GMT +1. The time now is 16:02.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.