String Specific Character Removal Function

Asked 2 years ago, Updated 2 years ago, 55 views

#include<stdio.h>
#include<ctype.h>
#define size 100

int main()
{
    char s[size] = "Applea";
    char c = "";
    c = getchar();

    int i, j;
    int n = 100;

    for (i = 0; i < n; i++)
    {
        if (s[i] == (char)c)
        {
            for (j = i; j < n; j++)
            {
                s[j] = s[j + 1];
            }
            n--;
            j--;
        }
        printf("%c", s[i]);
    }
    return 0;
}

It's a function to remove certain characters from a string, but I heard it's case-sensitive due to the characteristics of the string

Currently, if you enter a, only a is erased, and A is not erased, but you do not use the string processing function.

Is there a way to remove both A and A when entering a?

string c function

2022-09-20 16:37

1 Answers

#include <stdio.h>

int main()
{
    char s;
    s = 'Q';
    if (s > 70 && s < 90) {
        s = s + 32;
        printf("%c", s); // "q"
    }
    return 0;
}

https://goodgid.github.io/ASCII-Code/


2022-09-20 16:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.