top of page
Scanf
Scanf will be used to supply user input in C programming. When the program is executed the function will pause at a scanf function and wait for the user to type their input, after which it will continue. The scanf syntax is similar to printf but slightly modified;
An addressOf operator & will be used. This is because scanf uses pointers as arguments instead of variable names. While working with arrays however, the addressOf operator is unnecessary.
For standard variables: scanf("%i",&var); For array variables: scanf("%s",var);
Output:

Example:

Multiple inputs may be taken simultaneously in one function, this will use the format: scanf("%i%i",var1,var2);
This allows us to type both inputs in with a whitespace between them. The whitespace is the default delimiter used by scanf to separate inputs, we will look at changing the delimiter later on.

Output:
Example:

bottom of page