Does C have anything like the “substr\ (extract substring) routine present in other languages?
Not as such. (One reason it doesn’t is that, as mentioned in question 7.2 and section 8, C has no managed string type.) To extract a substring of length LEN starting at index POS in a source string, use something like char dest[LEN+1]; strncpy(dest, &source[POS], LEN); dest[LEN] = ‘\0’; /* ensure \0 termination */ or, using the trick from question 13.2, char dest[LEN+1] = “”; strncat(dest, &source[POS], LEN); or, making use of pointer instead of array notation, strncat(dest, source + POS, LEN); (The expression source + POS is, by definition, identical to &source[POS] –see also section 6.) 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