C language delete spaces in character array

A function to delete spaces in a character array, see code

#include <stdio.h>
#include <string.h>
#include <memory.h>
void clearStringAllspace(char *s)
{
    
    
    char *temp = s;
    while (*temp) {
    
    
        if(*temp != ' ' && *temp != '\t'){
    
    //这里一定不能是||
            *s++ = *temp;
        }
        temp++;
    }
    *s = '\0';
}
int main(int argc, char *argv[])
{
    
    
    char buf[] = "      abc   edf    ";
    clearStringAllspace(buf);
    printf("buf=%s=====\n", buf);
    return 0;
}

Guess you like

Origin blog.csdn.net/cp_srd/article/details/104279201