Home > Software engineering >  Could you tell me how to implement the string and array transformation?
Could you tell me how to implement the string and array transformation?

Time:09-28

Everybody is good, the problem in the title, I have a recording the string of Numbers, how to realize the string, array, array, the change of the string?

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 element

CodePudding user response:

Arrays, string
Define 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 of
Char * 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 sprintf

CodePudding user response:

refer to the original poster maoyefeng1 response:
hi, problem into the title, I have a recording the string of Numbers, how to realize the string, array, array, the change of the string?

Such as I have a string Str1, content is "123456789", how to convert an array?


String in memory is a an array, but also convert?

Char8 * p="ABCDEFG";
Char x=p [5];//x='F'
  • Related