What return type do sizeof() have? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

What return type do sizeof() have?

#include <stdio.h> int main() { printf("float: %ld \n", sizeof(float)); printf("double: %lu \n", sizeof(double)); printf("char: %ld \n", sizeof(char)); return 0; } //why is sizeof return type working with both %lu and %ld format specifier

18th Jul 2020, 9:10 AM
Godwin Baiju
Godwin Baiju - avatar
1 Antwort
+ 3
Naively speaking, it is illogical to try to represent size measurement by using negative number. So size measurement fits the characteristics of unsigned integer family. You *probably* may find incorrect or unexpected result when using signed integer %ld specifier when the size of the object to analyse (by sizeof) surpass the maximum value of signed integer data range.
18th Jul 2020, 10:09 AM
Ipang