answersLogoWhite

0

It is not certain if the question asked to convert lower case to upper case, or upper case to lower case. This answer assumes the latter. You could easily change this around for the former.

ConvertToLower (char*psz) {

while (*psz != '\0') {

switch (*psz) {

case 'A': *psz = 'a'; break;

case 'B': *psz = 'b'; break;

case 'C': *psz = 'c'; break;

case 'D': *psz = 'd'; break;

case 'E': *psz = 'e'; break;

case 'F': *psz = 'f'; break;

case 'G': *psz = 'g'; break;

case 'H': *psz = 'h'; break;

case 'I': *psz = 'i'; break;

case 'J': *psz = 'j'; break;

case 'K': *psz = 'k'; break;

case 'L': *psz = 'l'; break;

case 'M': *psz = 'm'; break;

case 'N': *psz = 'n'; break;

case 'O': *psz = 'o'; break;

case 'P': *psz = 'p'; break;

case 'Q': *psz = 'q'; break;

case 'R': *psz = 'r'; break;

case 'S': *psz = 's'; break;

case 'T': *psz = 't'; break;

case 'U': *psz = 'u'; break;

case 'V': *psz = 'v'; break;

case 'W': *psz = 'w'; break;

case 'X': *psz = 'x'; break;

case 'Y': *psz = 'y'; break;

case 'Z': *psz = 'z'; break;

}

psz++;

}

Warning. Do not be tempted to replace the switch statement with ...

if (*psz >= 'A' && *psz <= 'Z') *psz += 32;

... because that will only work on ASCII implementations, and it is most definitely not portable, such as in EBCDIC implementations.

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve

Add your answer:

Earn +20 pts
Q: Write program to convert a string in lower case without using library function?
Write your answer...
Submit
Still have questions?
magnify glass
imp