Programming Tips - Win32: C/C++ convert a string to title case

Date: 2022jun18 Languages: C/C++ Q. Win32: C/C++ convert a string to title case A.
void ToTitleCase(LPSTR s) { if (s == NULL) return; char prev = ' '; for (LPSTR p = s; *p; p++) { if (isalpha(*p)) { if (isspace(prev)) { *p = toupper(*p); } else { *p = tolower(*p); } } prev = *p; } }