current position:Home>What's wrong with this code that skips uppercase letters and only outputs lowercase letters?

What's wrong with this code that skips uppercase letters and only outputs lowercase letters?

2022-02-02 22:40:27 CSDN Q & A

img




Refer to the answer 1:

At the end of the function, add a s[i] = '\0'. Otherwise, the string terminator is still in its original place , The whole string will still be displayed .




Refer to the answer 2:



Refer to the answer 3:
void fun(char* s){    int i = 0;    char* p = s;    while (*p!='\0') {        if (*p>='a'&&*p<='z')        {            s[i] = *p;            i++;        }        p++;    }    s[i] = '\0';// End symbol is required , Invalidate what follows }



Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022240258921.html

Random recommended