사용자:하늘/메모장/docker

< 사용자:하늘‎ | 메모장
하늘 (토론 | 기여)님의 2021년 10월 15일 (금) 21:51 판
#include <stdio.h>
#include <string.h>

void delchars (char *str, char ch)
{
    int len = strlen(str);
    int i = 0;
    while ( i < len )    
    {
        if (str[i] == ch)
        {
           int j = i, width = 0;
            if ( str[i+1] == ch)
                width = 2;
            else
                width = 1;
            while (j < len)
                str[j] = str[j+width], j++;
        }
        i++;
    }
}
int main ( )
{
    char s1[128];
    strcpy(s1, "HelloWorld");
    delchars(s1, 'l');
    printf("[%s]\n", s1); // [HeoWord]
    delchars(s1, 'W');
    printf("[%s]\n", s1); // [Heoord]
}