4 ms·
With the "%.*s" format you need no null at the end. It just counts out the characters: #include <stdio.h> void main() { char buff[10] = {'R'
by jdougan 2y ago
With the "%.*s" format you need no null at the end. It just counts out the characters:
#include <stdio.h>
void main()
{
char buff[10] = {'R', 'o', 'b', 'o', 't', 't', 'y', 'p', 'e', 's'};
printf("=>%.*s<=", 4, ((char *)&buff + 3));
}
prints
=>otty<=
- jeffreygoesto 2y agoAh. Ok. Scanning the length before printing is mandatory then.