aquaballoon

C Pointer

Mar 15th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void){
  4.  
  5.  int num = 90;
  6.  int *pnum = &num;
  7.  printf("%d \n", num); // cup (coffee)
  8.  printf("%d \n", *pnum); // point to address (coffee)
  9.  printf("%p \n", &num); // address of cup
  10.  printf("%p \n", pnum); //cup (address of cup)
  11.  
  12.  printf("============ \n");
  13.  
  14.  char *grade = "A+"; // address of 'A' (0xbf83c4e4)
  15.  printf("%s \n", grade); // cup (converting the first address to string)
  16.  printf("%p \n", grade); // cup (the first address of string)
  17.  printf("%c \n", *grade); // point to the value of the first address (c)
  18.  printf("%d \n", *grade); // point to the value of the first address (d)
  19.  
  20. printf("== Insert Number =======>> \n");
  21.  
  22. int num1;
  23. scanf("%d", &num1);
  24. printf("%d \n", num1);
  25.  
  26. printf("== Insert any Words =======>> \n");
  27.  
  28. char *str;
  29. scanf("%s", str);
  30. printf("%s \n", str);
  31.  
  32.  return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment