void init(char v, char *buf, int n) { char *b = buf; while (b < buf+n) { *b++ = val; } } ... char *buf = malloc(2); init('A', buf, sizeof(buf));