I'm working on a project in which i need to create a string of arbitrary length and set all the characters to a specific character.
Example of setting bytes:
char str[i];
memset(str, '*', i);
str[i] = '\0';
This seems to work so far, however when I change the last line to str[i + 1] = '\0';
, my output is being shortened by one.
Can anyone explain why this is happening?