Home > Back-end >  Pointer to an array of
Pointer to an array of

Time:10-12

# include & lt; stdio.h>
Int main (void)
{? Char STR [100]="I am a" stuz;
? Char * p=& amp; STR [7].
? int i;
? for (i=0; STR [I]!='\ 0'; I++ p++)
? {? If (* p>='a' & amp; & * p<'z')
????? (* p) + +;
?? Else if (* p=='z')
????? * p='a';
? }
? Puts (STR);
? return 0;
}
Why the result is the last four letters back a, the rest remains the same?

CodePudding user response:

Suggested that learn to debug

CodePudding user response:

 if (* p>='a' & amp; & * p<'z') 
????? (* p) + +;

(* p) + + this is the first reference, and then put the reference value + 1,

The two statements is to make the 's' to 't', 't' into a 'u', 'u' into a 'v',
Then
 else if (* p=='z') 
????? * p='a';

The two statements is to make the 'z' into 'a';


Suggest the building still see code, the code is not complicated, it is easy to analysis, mainly is the four statements,

CodePudding user response:

? Char * p=& amp; STR [7].
Pointer to start from here, so did not change in front of
  • Related