std::string += operator cannot pass 0 as argument

The problem is that a literal 0 is a null pointer constant. The compiler doesn’t know if you meant:

std::string::operator +=(const char*);  // tmp += "abc";

or

std::string::operator +=(char);         // tmp += 'a';

(better compilers list the options).

The workround (as you have discovered) is to write the append as:

tmp += '\0';

(I assume you didn’t want the string version – tmp += nullptr; would be UB at runtime.)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)