There is no such thing. You'll have to either write a loop using printf or puts, or write a function that copies the string count times into a new string.
printf doesn't do that -- and printf is overkill for printing a single character.
char c = '*';
int count = 42;
for (i = 0; i < count; i ++) {
putchar(c);
}
Don't worry about this being inefficient; putchar() buffers its output, so it won't perform a physical output operation for each character unless it needs to.
Short answer - yes, long answer: not how you want it.
You can use the %* form of printf, which accepts a variable width. And, if you use '0' as your value to print, combined with the right-aligned text that's zero padded on the left..
printf("%0*d\n", 20, 0);
produces:
00000000000000000000
With my tongue firmly planted in my cheek, I offer up this little horror-show snippet of code.
Some times you just gotta do things badly to remember why you try so hard the rest of the time.
#include <stdio.h>
#include <string.h>
void repeat_char(unsigned int cnt, char ch) {
char buffer[cnt + 1];
/*assuming you want to repeat the c character 30 times*/
memset(buffer,ch,cnd); buffer[cnt]='\0';
printf("%s",buffer)
}
char buffer[41];
memset(buffer, '-', 40); // initialize all with the '-' character<br /><br />
buffer[40] = 0; // put a NULL at the end<br />
printf("%s\n", buffer); // show 40 dashes<br />