When encountering code that you don’t understand, and which is calling a function from a library, your first order of business is to research the documentation for that function. For C standard functions it’s enough to google the function name.
A good reference in this case is cppreference (don’t be misled by the website name, this is the C reference, not the C++ reference). It gives the function’s definition as
int scanf( const char *format, ... );
Now look for the parameter description of the format
parameter:
pointer to a null-terminated character string specifying how to read the input.
The subsequent text explains how to read the format string. In particular:
- […] character [except
%
] in the format string consumes exactly one identical character from the input stream, or causes the function to fail if the next character on the stream does not compare equal.
- conversion specifications [in] the following format
- introductory % character
- conversion format specifier
d
— matches a decimal integer.
In other words:
scanf
parses a textual input based on the format string. Inside the format string, /
matches a slash in the user input literally. %d
matches a decimal integer.
Therefore, scanf("%d/%d/%d", …)
will match a string consisting of three integers separated by slashes, and store the number values inside the pointed-to variables.