prev up next   top/contents search

comp.lang.c FAQ list · Question 13.4

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

A: 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>; see also question 13.5. (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; see question 7.5a.)

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

References: K&R1 Sec. 2.7 p. 40
K&R2 Sec. 2.7 p. 43

prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North