title: Why the type doesn't match in this value swap code in C?
body: <pre><code>void swap(char *a,char *b){
    char t;
    t = *a;
    *a = *b;
    *b = t;
  }
  int main(void){
    char  a = '1';
    char b = '2';
  
    swap(&amp;a,&amp;b);
    printf("The value is %c and %c respectively\n",a,b);
    return 0;
  }
  </code></pre>
  
  <p>in the above code, there's a spot that confuse me</p>
  
  <p>I think if <code>a</code> is a pointer, and <code>*a</code> is the value it points to</p>
  
  <pre><code>int *ptr, a = 1;
  
  ptr = &amp;a;
  printf("The value of *ptr should be a: %d\n",*ptr);
  printf("The value of *a should be an hex address: %p\n",ptr);
  </code></pre>
  
  <p>so in the <code>swap(char *a, char *b)</code> function,it takes the value not pointer( *a not a), </p>
  
  <p><code>swap(&amp;a, &amp;b)</code>
  but it actually pass the pointer value to it as the parameter, and the code works. Anybody can explain it to me?(I think for <code>swap(char *a){...}</code> part, the declaration doesn't mean it require *a to pass in, it means declare a pointer value <code>a</code>, not the value a points to as <code>*a</code>in elsewhere means).</p>