Monday, August 23, 2021

For all the CS Majors ou there

Hey,

Have you ever seen an integer subscripted by a string?

e.g.

#include


int main(int argc, char *argv[])
{
int a;
a = 4["JasonIsCool"];
printf("%d\n", a);
scanf("%d", &a);
return 0;
}
This code compiles and runs fine, and gives you different values depending on what you put in as the string and or/number. (3 and a give you 100 for example) What it does Find the "4th" character n the string. Interesting eh?

No comments: