char* replaceSpaces(char* S, int length){ char* s = (char*)calloc(length*3+1,sizeof(char)); int n = 0; for (int i=0; i<length; i++) { if (S[i] == ' ') { s[n++] = '%'; s[n++] = '2'; s[n++] = '0'; } else s[n++] = S[i]; } return s; }
char* replaceSpaces(char* S, int length){ char* s = (char*)calloc(length*3+1,sizeof(char)); int n = 0; for (int i=0; i<length; i++) { if (S[i] == ' ') { s[n++] = '%'; s[n++] = '2'; s[n++] = '0'; } else s[n++] = S[i]; } return s; }