CString str = ""; if (str.IsBlank()) { // do something if str is blank }
CString str = " "; if (str.IsBlank()) { // do something if str is blank (contains only spaces) }In this example, we create a CString object str with a value of five spaces. We then use the IsBlank method to check if str contains only whitespace characters. Since str contains no non-space characters, the method returns true. The CString class is part of the MFC library, which is included with Microsoft Visual Studio.