Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- play_with_pointers_v2.c
- Useful link for ASCII table
- http://www.asciitable.com/
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- int main()
- {
- char *str1 = "ABCDEFGHIJKLMNOPQRSTUVWXZYabcdefghijklmnopqrstuvwxzy";
- char *str = str1 + 26;
- printf("\n str1 = %s \n", str1 );
- printf("\n str = %s \n", str );
- printf("\n ---------------------- \n");
- printf("\n *((str--) ) ) = %c \n", *((str-- ) ) ); // a
- str++; // because we had str--
- printf("\n *((str-- + 2) ) = %c \n", *((str-- + 2) ) ); // c
- str++; // because we had str--
- printf("\n *((str-- + 2)+1) = %c \n", *((str-- + 2)+1) ); // d
- str++; // because we had str--
- printf("\n *((str-- + 2)+1)-3 = %c \n", *((str-- + 2)+1)-3); // a because d-3=a in ASCII table
- str++; // because we had str--
- printf("\n ---------------------- \n");
- printf("\n *(--str ) = %c \n", *(--str ) ); // Y
- str++; // because we had str--
- printf("\n *(--str+3) = %c \n", *(--str+3) ); // c
- str++; // because we had str--
- printf("\n *(--str+3)+32 = %c \n", *(--str+3)+32 ); // รข something in memory right from c, c+32 = ???
- str++; // because we had str--
- printf("\n ---------------------- \n");
- printf("\n *(++str ) = %c \n", *(++str ) ); // b
- --str; // because we had ++str
- printf("\n *(++str+2) = %c \n", *(++str+2) ); // d
- --str; // because we had ++str
- printf("\n *(++str+2)+4 = %c \n", *(++str+2)+4 ); // h because d+4=h in ASCII table
- --str; // because we had ++str
- printf("\n ---------------------- \n");
- return 0;
- }
Add Comment
Please, Sign In to add comment