An old classic, implemented to show off my pointers in C
An old classic I read when I was about 15 was the old HAL => IBM relationship. That is, by adding one to each character in HAL, we can end up with IBM. Funny, eh?
So when reading in K&R about the close relationship between pointers and arrays in C, I decided to crank up this little beauty.
char evil[] = "HAL";
for (char *ptr = evil; *ptr != '\0'; ++ptr) {
(*ptr)++;
}
printf("%s\n", evil); // HAL
Comments
No comments yet.
Leave a Comment
Note: Your comment may require approval before it is posted to the site.