char* generateSpace (int spaces) { int i; char *cSpaces; for (i = 0; i < spaces; i++) { if (!i) { // init string ptr with space [strcpy] strcpy(cSpaces, " "); } else { // append string with space [strcat] strcat(cSpaces, " "); } } cSpaces[spaces] = '\0'; return cSpaces; }