+ 1
When i use %d in place of %s I see this result, can you explain the number in place of string
3 Respuestas
+ 5
I originally thought that the resulting integer value represents the hex address of the (first character of the) string literal converted to decimal. Upon looking up threads and other resources, it appears that formatter and type mismatch for printf() simply results in undefined behaviour.
+ 3
You want to use %s for string values. To explain it simply, you basically told it to give you a numerical value for "apples" instead of its string value.
+ 3
Thanks for the info Hatsy. I've played around with it in the past, but the numbers never made any type of sense to me, so I didn't pursue it further since it wasn't necessary. I could conclude that it has nothing to do with the literal itself, as you'll get the same result regardless of the value. It's certainly related to the formatter, maybe referring to its position in the string relative to the other formatters so it knows where to place the value we give? Not certain the logic behind the exact number it gives, but it does seem to reference something in particular and is consistent with the number based upon the formatters relation to the other formatters. -shrug-