Home > Back-end >  Pointer to string copying
Pointer to string copying

Time:10-10

What is the meaning of the for loop

CodePudding user response:

Is the from pointer to the address of the element is not as' \ 0 'end (string) has been cycle, cycle in the from point to address the assign values to the elements to point to the address, and then increasing from and to a pointer is 1, the end of the for loop, the end of the string assignment to point to the address (also is equivalent to the to the end of the string to a character set to' \ 0 ',

CodePudding user response:

As long as the end of the first string didn't meet, I have been assigned to the second string

CodePudding user response:

String is 0 characters end, that is, '\ 0'
Char * p="123"; In fact the string is 1 2 3\0 of the memory stored in the memory of
Pointer, therefore, starting from the first character processing, move back each time, until met '\ 0', at this time until the end of the, string handling, circulation also dropped out

CodePudding user response:

reference 1st floor qybao response:
is the from pointer to the address of the element is not for '\ 0' end (string) has been circulation, circulation in the move from point to the address of the elements of the assignment to the to point to the address, and then increasing from and to a pointer is 1, the end of the for loop, the end of the string assignment to point to the address (also is equivalent to the to the end of the string to a character set to '\ 0',

For (;) This first; What is the meaning, the string b doesn't make sense?

CodePudding user response:

refer to the second floor qq_46221910 response:
as long as the end of the first string didn't meet, I have been assigned to the second string

For (;) The first; What do you mean?

CodePudding user response:

Fun
reference 3 floor response:
string, end is 0 characters, it is' \ 0 '
Char * p="123"; In fact the string is 1 2 3\0 of the memory stored in the memory of
Pointer, therefore, starting from the first character processing, move back each time, until met '\ 0', at this time until the string handling was finished, the cycle is out of the

Oh oh, that * to='\ 0' meaning doesn't work

CodePudding user response:

Not yes, in front of the for loop, the from 0 exit, to there is only written into the 123, also did not give the to end flag?
* to='\ 0' is set to end tag, very useful, cannot be omitted

CodePudding user response:

reference 5 floor weixin_46360087 reply:
Quote: refer to the second floor qq_46221910 response:
as long as the end of the first string didn't meet, I have been assigned to the second string

For (;) The first; What do you mean?

For loop has three parameters, with two a semicolon, fill to the first operation, second cycle judgment conditions, the third in finishing operations

CodePudding user response:

For ( expression; 2 ; expression {
)Cyclic code
}


The cyclic code, written completely equivalent to the following:

expression;
For (; ; ) {
if (! Expression 2) break;
Cyclic code
expression;
}

This is the for () inside a semicolon three expressions to perform the position and order of the

CodePudding user response:

For the syntax of the
For (the initial setting; Circulation conditions; After the end of each cycle set)
Each part is not necessary, can be null
for(; * the from!='\ 0'; From++ to++)
Initial set is omitted (because the from and to the direct use of parameter, requires no additional initialization)
* the from!='\ 0 is loop condition, said the from pointer didn't move to the end of the string
From++ to++ said end of each loop from and to increasing pointer 1
* to=* from copies the contents of the from point to address to the to point to the address of the
To the end of the for loop, *='\ 0' said to the last of the string position set for the end of the string

CodePudding user response:

Fun
reference 7 floor response:
not yes, in front of the for loop, the from 0 exit, to there is only written into the 123, also did not give the to end flag?
* to='\ 0' is set to end tag, very useful, can't omit

I just tried to remove * to, the result is the same, you all above 123\0, copy the past, meet \ 0 not will end?

CodePudding user response:

Fun, 9/f,
reference response:
for ( expression; 2 ; expression {
)Cyclic code
}


The cyclic code, written completely equivalent to the following:

expression;
For (; ; ) {
if (! Expression 2) break;
Cyclic code
expression;
}

This is for the three () inside a semicolon expressions to perform the position and order of the

For the understand, thank you

CodePudding user response:

Fun, 9/f,
reference response:
for ( expression; 2 ; expression {
)Cyclic code
}


The cyclic code, written completely equivalent to the following:

expression;
For (; ; ) {
if (! Expression 2) break;
Cyclic code
expression;
}

This is for the three () inside a semicolon expressions to perform the position and order of the

For the understand, thank you

CodePudding user response:

refer to the eighth floor qq_46221910 response:
Quote: refer to the fifth floor weixin_46360087 reply:
Quote: refer to the second floor qq_46221910 response:
as long as the end of the first string didn't meet, have been assigned to the second string

For (;) The first; What do you mean?

For loop has three parameters, with two a semicolon, ongoing operations of the first fill out, the second filling cycle judgment conditions, third fill finishing operations


Know what is called a blind cat touching the dead mouse?

Do you think *='\ 0'), Don't write the test code can also be a reason for this is that from and to preach and came in as long as the two strings
I am a the teacher
I am a student
Cover another, there is no problem with a
But if the two different edge length, for example,
You go to change, I am a tearch string into a
You are pig will see
Or become a longer
You are the big monkey
You could look at the results

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related