Ok say I have a string and I only want to print out so many chars.
printf("%*s\n",5,string+5);
This code does not place an upper limit on the number of characters to
be printed. It places a lower limit of 5.
If you want to insure that no more than 5 characters are printed, you
would use
printf("%.5s", address_of_first_character_in_string_to_be_printed)
If the maximum number of characters to be printed is computed and
stored in an int named n, then you could use
print("%.*s", n, address_as_described_above)
What exactly is this doing? Can one use -5 too in their if they wanted?
It is demonstrating that you are copying or generating code without
attempting to understand what the format string means to printf. Is
there some reason you could not look it up in your own reference?
n1256 is freely available and very clear on this point.
In the code you provided, using -5 for the second argument causes the
output to be left justified but still sets the minimum field width to
5.
Using -5 instead of +5 in the third argument is allowed only if string
points to an element at least 5 characters into a char array.