Please help me | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please help me

The first code works but second doesn't. Why? It's something with the format specifiers https://code.sololearn.com/c3tA6FIq8p1t/?ref=app https://code.sololearn.com/ccYWg6e8E0YB/?ref=app

19th May 2021, 10:23 AM
Rishi
Rishi - avatar
10 Answers
+ 4
See the warning from compiler: "/Playground/file0.c: In function 'main': /Playground/file0. c:10:40: warning: conversion lacks type at end of format FWformat= 101 printf "The decimal equivalent is: %l", li1);" Conversion lacks type at end of format. This tells us that 'l' stands for 'long', which is a type modifier, it doesn't represent a data type, although it does modify the meaning of a type, and adjusts accordingly how compiler treats the data. That was what XXX and Carbon was saying I guess.
19th May 2021, 11:58 AM
Ipang
+ 4
Rishi, It's not working (got a warning) because '%l' only defines the type modifier (long), but not the actual data type. "conversion lacks type at end" warning tells us to also define the type ('i' or 'd') apart from the type modifier 'l' in the conversion specifier. That's just about it I guess ...
19th May 2021, 12:08 PM
Ipang
+ 3
Because you used the wrong format specifier in the second code. See the tables in the following link to see all the format specifiers https://www.cplusplus.com/reference/cstdio/printf/
19th May 2021, 10:36 AM
XXX
XXX - avatar
+ 2
You did not give us what is your program supposed to do, but i will answer you my way. To avoid all issues remove the unused variables 'pEnd' and instead of this: printf ("The decimal equivalent is: %l", li1); Use this: "printf ("The decimal equivalent is: %ld", li1);" or this: " printf ("The decimal equivalent is: %li", li1); "
19th May 2021, 10:30 AM
Carbon
Carbon - avatar
+ 2
Rishi, It's just a nickname, Never mind ...
19th May 2021, 12:14 PM
Ipang
+ 1
XXX and Carbon , but isn't "%l" same as "%li" or "%ld"?
19th May 2021, 11:30 AM
Rishi
Rishi - avatar
+ 1
Ipang yes yes that's right but I remember studying that "%l" and "%li" are the same. Isn't that right? Then why does my code work only with "%li" and not "%l"?
19th May 2021, 12:04 PM
Rishi
Rishi - avatar
+ 1
Ipang okay thank you. I think I got it
19th May 2021, 12:10 PM
Rishi
Rishi - avatar
+ 1
Ipang your name is funny🥺
19th May 2021, 12:13 PM
Rishi
Rishi - avatar
0
Ipang 🥺🥺🥺
19th May 2021, 12:19 PM
Rishi
Rishi - avatar