how do I test if a character string is empty? (pointer to character)
char*s;
how do I test if a character string is empty? (pointer to character)
char*s;
Check if s[0] is equal to '\0'. You might also need to check if s itself is a null pointer, in which case it would not be pointing to the first char of an empty string, but simply be a null pointer.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I forgot to mention i am trying to read by cin>>s... which in fact doesn't allow me to introduce an empty string...what other alternative?
Use a std::string instead of a char*.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
thanks. more convenient, indeed