Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to determine size of variable without size of operator?

Status
Not open for further replies.

dilip_devaraj

Newbie level 3
Joined
Feb 18, 2006
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,299
C

how to determine size of a variable without using sizeof operator
 

C

I think in C++ we can use calass and its easy to use.
is it tru?
 

Re: C

Interesting question.

I would write the following code to find the size of an integer in bytes (assuming no sizeof command and byte = 8 bits):

Code:
int i = 1;
int count = 1;
while (i <<= 8)
{
    count++;
}
//count should contain the size of the integer i in bytes.
//don't try to do this with doubles.

In general, using the sizeof operator is a much better idea.

-jonathan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top