C Interview Questions and Answers

 

How do I convert a string to all upper or lower case?

Some libraries have routines strupr and strlwr or strupper and strlower, but these
are not Standard or portable. It's a straightforward exercise to write upper/lower-case
functions in terms of the toupper and tolower macros in <ctype.h>;(The only
tricky part is that the function will either have to modify the string in-place
or deal with the problem of returning a new string;



(Note also that converting characters and strings to upper or lower case is vastly
more complicated when multinational character sets are being used.)

Posted by:Richards