更新时间:2022-10-25 20:08:54
Nevermind,I STW,发现basic_str有一个项目访问方法c_str,似乎修复了编译问题。
到网站: http://en.cppreference.com/w/cpp/string/basic_string
I get the following error when this code is run:
syslog(LOG_ERR | LOG_USER, "%s",errorString);
cannot convert ‘const string {aka const std::basic_string}’ to ‘const char*’ for >argument ‘2’ to ‘void syslog(int, const char*, ...)’ inServer.cpp /PeCounter
line 478 C/C++ Problem
I am daemonizing the program and the errorString value prints just fine when outputted to stdio using cout, but it will not print when using a syslog call.
Any way to get std::basic_string(char) into the form of 'const char'.
Nevermind, I STW and found that basic_str has an item access method c_str which seems to fix the compile issue.
Here is the URL to the site: http://en.cppreference.com/w/cpp/string/basic_string