How to remove blank spaces from buffer [closed]

Most likely a (writable) string or a fixed array, which can be processed in place in O(n);

char* str = strdup("the big dog is cool"), *src = str, *dst = str;

while(*src) {
  if(*src != ' ')
    *dst++ = *src;
  src++;
}
*dst = 0;

// str is thebigdogiscool

Leave a Comment