How do we create datatypes in C++. Eg. creating datatype called "myowndatatype" with sizeof(myowndatatype) = 3
chound 1 Junior Poster
Recommended Answers
Jump to PostGreetings chound,
C provides typedef, a facility for creating new data type names. It makes your name a synonym of the defined data-type:
typedef int Number;
The type Number can be used in declarations and casts in exactly the same ways that the defined type int …
Jump to PostThis could be 3 bytes:
struct AThreeByteDatatype
{
char s[3];
};but on Windows the compiler is usually set to an alignment of 2 or 4, meaning that an array of these things will be a multiple of 4 not a multiple of 3.
struct AThreeByteDatatype twoOfThem[2];
…
All 8 Replies
C#Coder 0 Newbie Poster
Stack Overflow 8 Junior Poster
chound 1 Junior Poster
Stack Overflow 8 Junior Poster
C#Coder 0 Newbie Poster
Chainsaw 12 Posting Pro in Training
SLY985 0 Newbie Poster
BARI DANIYAL commented: can you give full code for begeiners because they dont about c++ +0
ravenous 266 Posting Pro in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.