::: spoiler 263 lines of code
```
#include
#include
//Function declarations
void promptchoice_main(void);
void promptchoice_main_again(void);
void promptinput(void);
void promptchoice_trim(void);
void executechoice(char choice_trim);
void trimnumbers(void);
void trimwhitespace(void);
void trimletters(void);
void trimspecial(void);
void specifyspecial(void);
void printresult(char input[]);
//Global variables
char choice_main = 0x00;
char choice_trim = 0x00;
char choice_detail = 0x00;
char input[1000] = "";
char previous_input[1000] = "";
//Remove specific numbers, letters, punctuation or whitespace characters from input.
int main() {
printf("\nWelcome! This program trims text by removing unwanted characters.\n"
while (1) {
if (strlen(previous_input) == 0) { // Check for previously trimmed text in memory.
promptchoice_main();
if (choice_main == 'E'
if (choice_main == 'T'
promptinput();
promptchoice_trim();
executechoice(choice_trim);
printresult(input);
}
}
else {
promptchoice_main_again();
if (choice_main == 'E'
if (choice_main == 'T'
promptinput();
promptchoice_trim();
executechoice(choice_trim);
printresult(input);
}
else if (choice_main == 'P'
sprintf(input, "%s", previous_input);
printf("\nYou are trimming previously trimmed text: %s\n", input);
promptchoice_trim();
executechoice(choice_trim);
printresult(input);
}
}
}
printf("\nGoodbye!\n"
return 0;
}
//Function definitions
void promptchoice_main(void) {
while (1) {
printf("\nPress T and ENTER to trim text or E and ENTER to exit: "
scanf("%c", &choice_main);
while (getchar() != '\n'
if (choice_main == 'T' || choice_main == 'E'
else { printf("\nInvalid input!\n"
}
return;
}
void promptchoice_main_again(void) {
while (1) {
printf("\nPress T and ENTER to trim new text, P and ENTER to trim previously trimmed text or E and ENTER to exit: "
scanf("%c", &choice_main);
while (getchar() != '\n'
if (choice_main == 'T' || choice_main == 'P' || choice_main == 'E'
else { printf("\nInvalid input!\n"
}
return;
}
void promptinput(void) {
printf("\nEnter the text that you would like to trim and press ENTER: "
fgets(input, sizeof input, stdin);
input[strlen(input) - 1] = '\0';
return;
}
void promptchoice_trim(void) {
while (1) {
int x = 0;
int n = 0;
printf("\nWhat would you like to trim?\n1) Numbers (1, 2, 3...)\n2) Whitespace (space, tab or newline) \n3) Letters (A,B,C... a,b,c...)\n4) Special characters (!,?, . , ...)\nType one of the above numbers and press ENTER: "
scanf("%c", &choice_trim);
while (getchar() != '\n'
if (choice_trim < 0x31 || choice_trim > 0x34) { printf("\nInvalid choice!\n"
else if (choice_trim == 0x31) {
for (n = strlen(input) - 1; n >= 0; n--) {
if (input[n] >= 0x30 && input[n] = 0; n--) {
if (input[n] == 0x20 || input[n] == 0x09 || input[n] == 0x0A) { x++; }
}
if (x == 0) { printf("\nNo whitespace found!\n"
else { break; }
}
else if (choice_trim == 0x33) {
for (n = strlen(input) - 1; n >= 0; n--) {
if (input[n] >= 0x41 && input[n] < 0x5A || input[n] >= 0x61 && input[n] = 0; n--) {
if (input[n] >= 0x21 && input[n] < 0x2F || input[n] >= 0x3A && input[n] < 0x40 || input[n] >= 0x5B && input[n] < 0x60 || input[n] >= 0x7B && input[n] = 0; n--) {
if (input[n] >= 0x30 && input[n] = 0; n--) {
if (choice_detail == 'S'
else if (choice_detail == 'T'
else if (choice_detail == 'N'
else if (choice_detail == 'A'
}
return;
}
void trimletters(void) {
int x = 0;
int n = 0;
while (1) {
printf("\nType U to trim uppercase letters, L to trim lowercase letters or A to trim all letters: "
scanf("%c", &choice_detail);
while (getchar() != '\n'
if (choice_detail != 'U' && choice_detail != 'L' && choice_detail != 'A'
else if (choice_detail == 'U'
for (n = strlen(input) - 1; n >= 0; n--) {
if (input[n] >= 0x41 && input[n] = 0; n--) {
if (input[n] >= 0x41 && input[n] = 0; n--) {
if (input[n] >= 0x61 && input[n] = 0; n--) {
if (input[n] >= 0
23 Jun 2026 14:44