Time to get printf to the SIZE_MAX off the ground. Especially since it's not the type that matters for the precision specifier for the string size, it's the actual value.
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
int main() {
enum { COUNT = 10, BYTESIZE = INT_MAX / COUNT };
char* str = (char*)malloc(BYTESIZE + 1);
for (size_t i = 0; i < BYTESIZE; ++i) {
str[i] = 'a';
}
str[BYTESIZE] = '\0';
FILE* f = fopen("/dev/null", "w+");
[[maybe_unused]] int write_value = fprintf(f, "%.*s", BYTESIZE, str);
[[maybe_unused]] int large_write_value = fprintf(f, "%.*s %*.s %*.s %*.s %*.s %*.s %*.s %*.s %*.s %*.s %*.s",
BYTESIZE, str, BYTESIZE, str, BYTESIZE, str, BYTESIZE, str, BYTESIZE, str, BYTESIZE, str, BYTESIZE, str,
BYTESIZE, str, BYTESIZE, str, BYTESIZE, str, BYTESIZE, str);
free(str);
assert(write_value == BYTESIZE); // Well.
assert(large_write_value == -1); // ... Okay.
// this should let the other thing work out nicely, then.
return 0;
}