Answer the question
In order to leave comments, you need to log in
How to formulate the cycle correctly so that it stops checking “this is a number” when it is already followed by a letter?
for (pch = s1; *pch; ++pch) {
if (isalpha(*pch))
*pch = islower(s1[0]) ? tolower(*pch) : toupper(*pch); // ternary operator
else if (isdigit(*pch)) {
while (isdigit(*pch) && isalpha(*pch++))
pch++;
}
7ello, World!!111oneONEone
7ello, world!!111oneoneone
7eLLO, WORLD!!111oNEONEONE
Answer the question
In order to leave comments, you need to log in
https://pastebin.com/4rrDRWgw
char *pch;
for (pch = s1; *pch; pch++) {
if (isalpha(*pch)) {
if (isupper(s1[0]))
*pch = toupper(*pch);
else
*pch = tolower(*pch) ;
}
else continue;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question