
Write a function that says whether the product n * size fits in a size_t, writing that product through out when it fits and leaving out alone when it does not.
checked_size(1000, 24, &out)1
24000checked_size(0, 8, &out)1
0checked_size(3, SIZE_MAX / 3, &out)1
18446744073709551615checked_size(SIZE_MAX, SIZE_MAX, &out)0checked_size(SIZE_MAX, 2, &out) with out = 777, out printed either way0
777checked_size.c<stddef.h>defines size_t<stdint.h>defines SIZE_MAX
Run the tests to grade your code
Write a function that says whether the product n * size fits in a size_t, writing that product through out when it fits and leaving out alone when it does not.
checked_size(1000, 24, &out)1
24000checked_size(0, 8, &out)1
0checked_size(3, SIZE_MAX / 3, &out)1
18446744073709551615checked_size(SIZE_MAX, SIZE_MAX, &out)0checked_size(SIZE_MAX, 2, &out) with out = 777, out printed either way0
777checked_size.c<stddef.h>defines size_t<stdint.h>defines SIZE_MAX
Run the tests to grade your code
Memory will appear here