#include #include void removeChar(char* str, char charToRemove) { size_t len = strlen(str); size_t i, j = 0; for (i = 0; i < len; i++) { if (str[i] != charToRemove) { str[j++] = str[i]; } } // Null terminate the modified string str[j] = '\0'; } int main() { char inputString[100]; // 任意のサイズを設定できます char charToRemove; printf("文字列を入力してください: "); scanf_s("%s", inputString, (unsigned)sizeof(inputString)); printf("削除する文字を入力してください: "); scanf_s(" %c", &charToRemove, 1); removeChar(inputString, charToRemove); printf("変更後の文字列: %s\n", inputString); return 0; }