Remove Trailing Whitespace String Characters | C Programming Example

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Best explanation out on this topic, exactly what I needed, thank you

evankarabas
Автор

White space is frustrating when using stringent formatting such as Betty.

sheyig
Автор

What if you want to remove backspaces/whitespaces in the middle of a sentence and not just in the end?

vahidilhomov
Автор

what if i want to replace double slash to single in a string ?

khadijaghulamrasool
Автор

Nice! :
// An alternative approach
void trim_trailing(char *string){
if(!string) return;
int i = strlen(string)-1;
while(isspace(string[i]) && i > 0){
--i;
}
// OFC the if statement is not necessary
if(i != strlen(string)-1)
string[i+1] = '\0';
}

justcurious
Автор

name = input("name: ")
birth_year =input("Enter your birth year: ")
age2 = 2022 - int(birth_year)
patient_status = input("new or old?: ")
print("name " + name)
print("age ", age2 )
print("status "+ patient_status)
print("Welcome " + name)

hitoriotaku