Beruflich Dokumente
Kultur Dokumente
static void removeSpaces (char *str) { // Set up two pointers. char *src = str; char *dst = src; // Process all characters to end of string. while (*src != '\0') { // If it's not a space, transfer and increment destination. if (*src != ' ') *dst++ = *src; // Increment source no matter what. src++; } // Terminate the new string. *dst = '\0'; } int main (void) { char str[] = printf ("Old removeSpaces printf ("New return 0; }
"This is a long string with string is [%s]\n", str); (str); string is [%s]\n", str);
lots of spaces...
";