# Include <stdio. h>
# Include <string. h>
Using namespace STD;
Int main ()
{
String;
A [0] = 'a ';
A [1] = '/0 ';
Printf ("% s/n", );
System ("pause ");
}
Error: [Warning] cannot pass objects of non-pod type 'struct STD: String 'pass'... '; call will abort at runtime
Printf can only Output Data Built-in C language, while string is not built-in, but an extended class. This is definitely a link error. String is not equal to char *. & A indicates the storage address of the string, not the first address of the string. The AA object contains a pointer to "string, & AAR obtains the address of this object, not the address of "string.
This operation should be performed on the string type output by printf!
# Include <iostream>
# Include <string>
Using namespace STD;
Void main ()
{
String AA = "qqq ";
Printf ("% s", AA. c_str (); // not recommended
// Or cout <;
}
Because string is an extension type of C, you can use the method provided by string to assign values to data: Assign (const char *) or directly use its constructor.
String STR ("Now is the time ...");