Can you help me why %n specifier is used for in this programming example that i get from deitels book.
Code:
#include <stdio.h>#include <stdlib.h>
#include <time.h>
int main()
{
int a[10] = { 0 }; /* random integers from 1 to 1000 */
int i; /* loop counter */
int count; /* number of characters in current value */
int totalCount = 0; /* total characters in array */
srand(time(NULL));
/* fill the array with random numbers */
for (i = 0; i <= 9; i++) {
a = 1 + rand() % 1000;
} /* end for */
/* print table headers */
printf("%s\t%s\n", "Value", "Total characters");
/* loop through 10 elements */
for (i = 0; i <= 9; i++) {
printf("%d%n", a, &count);
totalCount += count; /* update totalCount */
printf("\t%d\n", totalCount);
}
}