title: how check null pointer in c programming , get this compile error: used struct type value where scalar is required ,
body: <pre><code>struct s_client *cur_client(void){
      return (struct s_client *) pthread_getspecific(getclient);
  }
  
  
  
  int32_t chk_process (int32_t) {
  ...
  struct s_client *ptr = cur_client();
  
  //FIXME
  // how could i check in this line , just when the value of 
  // ptr is not zero , then it goes to it's next line?`
  
  send_data (ptr, index);
  ...
  ...
  }
  </code></pre>
  
  <p>i would like to check , only at the time that the value of ptr , is not zero , it goes to it's next line , i tried this line of code </p>
  
  <pre><code>if (*ptr != 0)
  </code></pre>
  
  <p>but as  expected this wasn't correct , since it's not check the value !</p>
  
  <p>Edit2 :
  Well , i found myself the reason , since ptr fullfilled from pthread_getspecific . If pthread_getspecific is called on the key whose thread specific data is being destroyed, the value NULL is returned. For more info , u could check the man page ... End of the story</p>
  
  <p>Edit1 :</p>
  
  <p>Well This is the struct name cur_client() , which is use in above codes </p>