Difference between uint32_t vs unsigned int
- uint32_t is defined in stdint.h header file, so we have to include this header file if we want to use uint32_t
- It is guaranteed to be a 32-bit unsigned integer
- unsigned int
- Like int, unsigned int typically is an integer that is fast to manipulate for the current architecture
- so it's to be used when a "normal", fast integer is required.
- For example, on a 16 bit-processor unsigned int will typically be 16 bits wide, while uint32_t will have to be 32 bits wide.
Program:
/* Difference between uint32_t vs unsigned int by Velraj.K * Check : http://velrajcoding.blogspot.in */ #include<stdio.h> #include <stdint.h> /* For uint32_t */ int main() { /* It is guaranteed to be a 32-bit unsigned integer */ uint32_t int32_val = 0; /* Like int, unsigned int typically is an integer that is fast to manipulate for the current architecture. * so it's to be used when a "normal", fast integer is required. * For example, on a 16 bit-processor unsigned int will typically be 16 bits wide, while uint32_t * will have to be 32 bits wide. */ unsigned int uint_val = 0; printf("Vel value int32_val:size <%u:%zu> uint_val:size <%u:%zu> \n", int32_val, sizeof(int32_val), uint_val, sizeof(uint_val)); return 0; }
Output:
velraj@velraj-H310M-H:~/velraj/cLang$ ./a.out
Vel value int32_val:size <0:4> uint_val:size <0:4>
No comments:
Post a Comment