I've been trying to read all I can about the %n conversion specifier, but I'm having trouble with it. In the following code, I generate ten random numbers between 1 - 1000 and save each to an element of the array. I need to use %n to keep a running total of the characters, but can't get it to work. Any idea how to do this?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int x;
int num[10] = {0};
int count = 0;
int total = 0;
int _set_printf_count_output = 2;
srand(time(NULL));
for(count = 1; count <= 10; count++)
{
x = 1 + (rand()%1000);
num[count] = x;
printf( "Value:%d\tTotal Characters:%d\n", x, total);
}
return 0;
}