A quick search brings up thsi nice solution here
Quote Originally Posted by http://wiki.answers.com/Q/Can_you_specify_variable_field_width_in_a_scanf_fo rmat_string_If_possible_how
You can't specify a variable field with a fixed format string, but you can get around this by making the format string variable:
Code:
 int width;
 char format[20];  /* or whatever size is appropriate */
 int value;

 ...
 sprintf(format, "%%%dd", width); /* generates a string like "%5d" */
 scanf(format, &value);
This example is for "scanf", but of course can be applied to "sscanf".