Such as I have a string Str1, content is "123456789", how to convert an array?
CodePudding user response:
cstrings STR=TEXT (" CSDN ");
Int length=STR. GetLength ();
//cstrings overloading the type conversion to LPCTSTR
LPCTSTR PSZ=(LPCTSTR STR);
//pointer PSZ can be used like TCHAR array
For (int I=0; I & lt; length; I++) {
Cout & lt;}
CSDN cstrings STR=TEXT (" ");
Int length=STR. GetLength ();
//cstrings overloading the [] operator to access the character array element
For (int I=0; I & lt; length; I++) {
Cout & lt;}
STD: : string STR="CSDN";
Int length=STR. Length ();
Const char * PSZ=STR. C_str ();
//pointer PSZ can be used as a char array
For (int I=0; I & lt; length; I++) {
Cout & lt;}
STD: : string STR="CSDN";
Int length=STR. Length ();
//STD: : string overloading the [] operator to access the character array element
For (int I=0; I & lt; length; I++) {
Cout & lt;}
CodePudding user response:
http://edu.csdn.net/course/detail/2344 C language pointer and assembly - a memory address. The code elementCodePudding user response:
Arrays, stringDefine a character array, and then use memcpy copy content into the new array;
Arrays, string
Directly to a string variable, array pointer assignment
CodePudding user response:
Define a char array, and then a strcpy, memcpy, memmove, strncpy, STRXFRM,CodePudding user response:
String pointer can access as an array ofChar * pbufs="12345678";
Int len=strlen (pbufs);
for(int i=0; I
Printf (" % c ", pbufs [I]);//like array access string.
}
CodePudding user response:
See if can solve the sprintfCodePudding user response: