title: Printing pointer addresses in C [two questions]
body: <p>I know that my questions are very simple but googleing them didn't get me any useful results... They'r probably too simple!!</p>
  
  <p>No. 1</p>
  
  <pre><code>char* createStr(){
      char* str1 = malloc(10 * sizeof(char));
      printf("str1 address in memory : %p\n", &amp;str1);
      return str1;
  }
  
  int main(void){
      char* str2 = createStr();
      printf("str2 address in memory : %p\n", &amp;str2);
  }
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>str1 address in memory : 0x7fffed611fc8
  str2 address in memory : 0x7fffed611fe8
  </code></pre>
  
  <p>Why are the addresses different in and out of the createStr() function and how can I free(str1)??? </p>
  
  <p>No. 2</p>
  
  <pre><code>int main(int argc, int *argv[]){
      printf("Basename is %s ", (char*) argv[0]);
      if(argc &gt; 1 ){
          printf("and integer arg is : %d.\n", (int) *argv[1]);
      }
  }
  </code></pre>
  
  <p>If I compile and run <code>$ ./test 3</code>, how can I get int 3?</p>
  
  <p>Result:</p>
  
  <pre><code>Basename is ./test and integer arg is : 1380909107.
  </code></pre>