What are some safe sized datatypes? Inother words, stuff like size_t, uint32_t. They don't seem to change no matter what machine I use. I'm asking because the confusion comes in here:

I'm not sure when to use long vs int. I did a sizeof(int) and sizeof(long) and they are both 4 bytes and I'm on a 64bit machine. Now I always though long would be 8 bytes or hold larger sized integers but this is not the case. This goes the same for long double and double. They seem to also be the same size whereas I though long double would be larger.

Are there any large integral data types that are guaranteed?

I'm not sure when to use long vs int.

Use long when the value stored in the variable may exceed 16 bits. int is only guaranteed to be at least 16 bits and long is only guaranteed to be at least 32 bits. C++11 supports the long long data type, which is guaranteed to be at least 64 bits.

This goes the same for long double and double.

long double is only required to be at least as large as double.

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.