Scanning dependencies of target algorithm
[ 50%] Building CXX object CMakeFiles/aaa.cpp.o
error: cannot pass non-trivial object of type ‘string’
(aka ’ basic_string< char, char_traits< char >, allocator< char > >’) to variadic function;
expected type from format string was ‘char *’ [-Wnon-pod-varargs]
printf(“%s\n”, lines);
~~ ^~~~~
note: did you mean to call the c_str() method?
printf(“%s\n”, lines);
^
.c_str()
1 warning and 1 error generated.
printf、scanf、fprintf使用%s处理string字符串只能使用C的string使用C++的String需要先转化为C的string
string str ("Test string");
printf("%s\n", str.c_str());
Reference:
http://blog.csdn.net/jiujie_/article/details/8722083