2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C言語で文字列内の数字文字を消すプログラム(自作)

Posted at
# include <stdio.h>

void delnum(char s[])
{
    int i = 0;
    int j;    

    while (s[i]) {
        while ('0' <= s[i] && s[i] <= '9') {
            j=i;
            while(s[j]!='\0'){
                s[j]=s[j+1];
                j++;
            }
        }
        i++;
    }
/* いい線いってると思うけど・・・ */
}

int main(void)
{
    char str[] = "3Hello2Wo1ld9!";
    printf("%s\n", str);
    delnum(str);
    puts("チェーーーンジ!!!");
    printf("%s\n", str);
    return 0;
}
2
1
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?