This code works properly but there is a bug! Why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

This code works properly but there is a bug! Why?

This C language code calculates the size and length of a character array... this code works properly but there is a bug! Why? https://code.sololearn.com/cC2GsfxEh6Zf/?ref=app

20th Mar 2022, 12:21 PM
Amateur
3 Answers
+ 1
sizeof() function return value of type "long unsigned int". But you are using %d so you may lose data if return value is out of int range.. That's what compiler telling.. Use %ld instead of %d. It works fine. printf("Size of C in bytes = %ld\n", sizeof(C)); hope it helps...
20th Mar 2022, 12:27 PM
Jayakrishna 🇮🇳
0
Jayakrishna🇮🇳 Thank u ⚘⚘⚘
20th Mar 2022, 12:50 PM
Amateur
0
You're welcome...
20th Mar 2022, 12:50 PM
Jayakrishna 🇮🇳