This surprised me a bit with a smattering of pointer, I try to tell me not mature idea, bosses, please help me to analysis analysis, to see if I understand what are the wrong place,
Here is my code
#include
#include
#include
#include
Void main ()
{
Char a [1024], * c.
Gets (a);
Int len=0;
Len=strlen (a);
C=& amp; A [len];
Gets (c);
Puts (a);
}
My idea is: in the first time after receive the string a, no longer to set up a new string b, but c using pointer,
Pointer is the address of the c: through gets () after the end of a place, it should be the default use '\ 0' replace '\ n', and I will be '\ 0' address
Assigned to a pointer, c and c from pointer points to the address of the beginning, continue to gets (), this is equivalent to continue in a character array
Accepts, and receives the original receiving the behind of the string, in the final with puts () unified print it out, I don't know whether others have
And I a similar approach, but this method is really hit me thought, trying to knock, unexpectedly really implemented,
Also bosses, please help me to look at, look at me not enough understanding of the pointer if there is any place, please!
@ QZJHJXJ @ confident boy
CodePudding user response:
Well,I have a few questions:
1, defines the character array after such as char b [1024]; If does not carry on the initialization, then its value of each element is a random value, or '\ 0'?
2, gets () on a string value is the default in the string after add '\ 0' bottom?
3, puts () what is the end of the print logo?
Bosses in spite of being very busy toglance can solve the younger brother of doubt,,, @ QZJHJXJ @ confident boy