What does the syntax ‘%s’ and ‘%d’ mean as shorthand for calling a variable?

They are format specifiers, meaning a variable of a specified type will be inserted into the output at that position. This syntax works outside of classes as well.

From the documentation:

d – the argument is treated as an integer, and presented as a (signed)
decimal number.

s – the argument is treated as and presented as a string.

See the manual on printf. For a list of format specifiers, see here.

Leave a Comment