How to pass addresses to a scanf() function in C?

In scanf() function the variables that are receiving values should be passed by their addresses. All arguments should be pointers to variables.

For Example:

To read an integer:

scanf(“%d”, &i);

To read a string:

scanf(“%s”, str);

Since string is already a pointer & is not required.

Leave a Reply