Couldn't find it either googling it or in the lectures so far. Does somebody have the complete options and what they are for? Thank you very much.
printf formatting is a language unto itself. This document helped me a lot. Hope you find it useful.
These characters are used as "wildcards" or placeholders. They are used in conjunction with something like printf().
Very basic example //declaring an int variable to a value of 5 int x = 5;
//printing "%i" using the value of X printf("%i", x);
Result would print: 5
This is because printf is accepting 2 parameters here. When you use "%i", it then expects the user to pass another parameter, to replace this placeholder that was initially given. They are used because the value of x will not ALWAYS be 5 in an example program, so instead of saying printf("5"), it will now print whatever value is given to the second parameter, in this case X.
More complex but practical example a program is used to post a group of orders but if there is an error, tell the user which order needs to be fixed.
if (some error occurs)
printf("Order %i could not be posted.", CurrentOrderNumber)
result: Order 2352 could not be posted
In this case as it looped through the orders trying to post them, order 2352 produced an error, so this will replace %i, with the CurrentOrderNumber. By doing so all orders with errors will be printed and the user will know which order needs to be fixed