catalog
1. Problem description 2. Cause analysis 3. Solution
1. Problem description
When running the program, the compiler reports an error:
error: cannot pass objects of non-trivially-copyable type ‘std::string {aka struct std::basic_ string}’ through ‘…’ |
2. Cause analysis
The error is displayed on this line:
printf("%c %s %lld %lld\n", p, edges, ver, edge);
Where edges is of string type.
Grammar:
const char *c_ str();c_ Str() function returns a pointer to a normal C string, the content of which is the same as that of this string string. In order to be compatible with C, there is no string type in C, so it must pass the member function C of string class object_ Str () converts a string object to a string style in C.
3. Solutions
In use, add C_ str();
printf("%c %s %lld %lld\n", p, edges.c_str(), ver, edge);
Read More:
- C language string processing error warning, c4996, sprintf, predicted, c4996, strcpy, c4996, strcat
- Differences between length() size() and C strlen() of C + + string member functions
- Type error: cannot unpack non Iterable non type object appears when starting Bert server in Ubuntu system
- Error: unrecognized command line option “-std=c++11”, to solve the problem that ubuntu does not support c++11
- C++ string substr()
- Solution to the problem of no C / C + + option in the new project of eclipse
- Solutions to error c2143: syntax error: missing ‘;’ before ‘type’ in C + + program compilation
- C language — to solve the problem of program flashback when programming (in VS)
- error C2057: expected constant expression (Can the size of an array in C language be defined when the program is running?)
- C error C2143 syntax error missing before ‘type’
- C++:error C2228: left of ‘.str’ must have class/struct/union
- How to solve the problem that the output results of C + + program written in VS2010 flash by
- To solve the problem of C # calling excel interface error, prompt: the COM object of Microsoft. Office. Interop. Excel. Applicationclass is forcibly converted to the interface type “Microsoft. Offi”
- Error c2137 of C language: empty character constant (Fixed)
- C + + common errors: “error: XXX in namespace ‘STD’ does not name a template type”
- C++ foundation — clear/erase/pop of string class_back
- Solve the problem that WSL occupies too much C disk
- To solve the running error of eclipse for C / C + +: launch failed binary not found
- C++ Error: allocating an object of abstract class type
- The use of Chinese characters in Qt and the solution to the “error C2001: newline in constant” problem