Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <inttypes.h>
- int main (int argc, char **argv)
- {
- char pTestStr[] = "148";
- char *pStrPointer = pTestStr;
- printf("Test01. Value: %c pTestStr: %s\n", *pStrPointer+1, pTestStr);
- printf("Test02. Value: %c pTestStr: %s\n", pStrPointer[1], pTestStr);
- printf("Test03. Value: %c pTestStr: %s\n", *pStrPointer, pTestStr);
- printf("Test04. Value: %c pTestStr: %s\n", *pStrPointer++, pTestStr);
- printf("Test05. Value: %c pTestStr: %s\n", *pStrPointer, pTestStr);
- printf("Test06. Value: %c pTestStr: %s\n", (*pStrPointer)++, pTestStr);
- printf("Test07. Value: %c pTestStr: %s\n", *pStrPointer, pTestStr);
- printf("Test08. Value: %c pTestStr: %s\n", ++*pStrPointer, pTestStr);
- printf("Test09. Value: %c pTestStr: %s\n", *pStrPointer, pTestStr);
- printf("Test10. Value: %c pTestStr: %s\n", *++pStrPointer, pTestStr);
- printf("Test11. Value: %c pTestStr: %s\n\n", *pStrPointer, pTestStr);
- printf("TestAddr1. Address: 0x%" PRIXPTR "\n", (uintptr_t) &pTestStr); //address of array
- printf("TestAddr2. Address: 0x%" PRIXPTR "\n\n" , (uintptr_t) &pTestStr[0]); //address of the first element of an array
- /*
- output:
- Test01. Value: 2 pTestStr: 148
- Test02. Value: 4 pTestStr: 148
- Test03. Value: 1 pTestStr: 148
- Test04. Value: 1 pTestStr: 148
- Test05. Value: 4 pTestStr: 148
- Test06. Value: 4 pTestStr: 158
- Test07. Value: 5 pTestStr: 158
- Test08. Value: 6 pTestStr: 168
- Test09. Value: 6 pTestStr: 168
- Test10. Value: 8 pTestStr: 168
- Test11. Value: 8 pTestStr: 168
- TestAddr1. Address: 0x7FFD21F683E4
- TestAddr2. Address: 0x7FFD21F683E4
- */
- return 0;
- }
Add Comment
Please, Sign In to add comment