I deal with pointers in c, and when I run the following code, I get "l" as the output! Why?
char *s = "Hello, World!"; printf("%c", 2[s]);
What does 2 [s] mean?
Prints s [2] , which is equal to l. This is because s [i] is syntactically equal to * (s + i) . Therefore, s [2] and 2 [s ] are converted to * (s + 2).
2[s] matches s[2] because the compiler converts both values ββto *(2 + s)
2[s]
s[2]
*(2 + s)
here's a good link for you: why are both the [array] and array [index] indices valid in C?
both s [2] and 2 [s] are the same. This creates the compiler C. Internally, s [2] is treated as * (s + 2). which is similar to 2 [s].
2 [s] is the same as s [2], which can be written as * (s + 2).
This is another way to write s[2] , they mean the same thing. In this case, it will print the third character of your string, which is "l"
Source: https://habr.com/ru/post/1482133/More articles:A regular expression is required to test at least 3 uppercase, 3 lowercase, 3 digits and 3 special characters - regexCDATA in factory payload in WSO2 ESB - xmldetection of equivalence typedefs - c ++Troubleshooting Error Using Label Filter in Django Template - djangoPython - concatenate a string to include one backslash - pythonSolr type restriction - tomcatPlay Framework 2, AngularJS and internationalization - angularjshttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1482136/how-to-check-if-user-has-granted-the-access-to-facebook-or-not&usg=ALkJrhjSEspwhZ1BNWj9olICgFPY7eG5uADebugging a deployed cloud service application - azurepython nosetests won't work - pythonAll Articles