Home > Back-end >  Senior c language array defined problem
Senior c language array defined problem

Time:10-09

Accidentally saw a code before
C="/4/3/2 1/5/6" [I]
Double quotes part can be viewed as an array
The desired effect I=1, c=4
Before the bosses expected what you played less than expected

CodePudding user response:

Theoretically possible, maybe it's a different compiler to handle different, LZ, what kind of results and different expectations?
"/4/3/2/1/5/6" is a string constant pointer, pointer [I] is to take the ith element, equivalent to
Const char * p="/4/3/2/1/5/6";
C=p [1];

CodePudding user response:

reference 1st floor qybao response:
could theoretically, maybe it's a different compiler to handle different, LZ, what kind of results and different expectations?
"/4/3/2/1/5/6" is a string constant pointer, pointer [I] is to take the ith element, equivalent to
Const char * p="/4/3/2/1/5/6";
C=p [1];
compiler/also count as one of the elements

CodePudding user response:

Isn't that right? I=1 c=4, is the c/I is 0, the array subscript begins with 0, that is to say/is also one of the elements, because it is one of the characters,
  • Related