CCoding Style - Be careful with side effects2
Be careful with side effects ...
str[i++] = str[i++] = ' ';
The intent is to store blanks at the next two positions in str. But depending on when i is updated, a position in str could be skipped and i might end up increased only by 1.
Break it into two statements:
str[i++] = ' '; str[i++] = ' ';
Even though it contains only one increment, this assignment can also give varying results:
array[i++] = i;