Flip a string's lowercase characters to uppercase and vice versa | C Programming Example

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

u can use ASCII instead of ctype library

qaish
Автор

Why can you get the size of a string array inside a function? Shouldn't this fail just like it would if you'd use an int array since you only pass a pointer into the function? Is it because this function has no return value or is this something specific to strings?

gregorO
Автор

Alternative solution:

void letter_flip(char *str){
char *p;
for(p = str; *p != '\0'; p++) {
if(*p >= 65 && *p<= 90)
*p += 32;
else if(*p >= 97 && *p<= 122)
*p -= 32;
else
*p = *p;
}
}

thanks for the videos as always

DaiMoscv
Автор

Thanks, great video :
// Alternative solution using ternary operator
void vice_versa(char *string){
int length = strlen(string);
int i = 0;
while(i<length){
islower(string[i]) ? (string[i] = toupper(string[i])) : (string[i] = tolower(string[i]));
++i;
}
}

justcurious
Автор

What does s[i] means why that i char is using in it

s_arc
visit shbcf.ru