Programatically Finding Integer Size

Paul paul at all-the-johnsons.co.uk
Sat Oct 11 08:34:33 UTC 2003


Hi,

> I'm learning C++. Can someone tell me the accepted way to 
> programatically determine the size of integers on a given system using C++?

cout << sizeof(T) << endl;

should do the trick. T is a generic term for type - you can replace it
with int, char, short etc etc etc (though it is pointless to use char as
it is *always* 1). Remember though, the sizeof value does not say the
number of bits there are in that size. I have seen upto 15 bits in a
byte before now.

Have a toddle over to my really good friends at http://www.accu.org,
join up and join the excellent learner programmer lists :-)

TTFN

Paul

-- 
One OS to fool them all
One browser to find them
One email client to bring them all
And through security holes, blind them...





More information about the fedora-test-list mailing list