Prob comparing pointers and integer in C

Posted by Dimitri on Stack Overflow See other posts from Stack Overflow or by Dimitri
Published on 2010-06-17T16:12:29Z Indexed on 2010/06/17 16:23 UTC
Read the original article Hit count: 201

Filed under:
|

Hi I have a problem with this code. When i am using this function I have no warnings. :

    void handler(int sig){
   switch(sig) {
     case SIGINT : { click++; fprintf(stdout,"SIGINT recu\n");
                           if( click == N){
                             exit(0);
                           }
   }
     case SIGALRM : fprintf(stdout,"SIGALRM received\n");
                    exit(0);
     case SIGTERM:  fprintf(stdout,"SIGTERM received\n");
                     exit(0);


  }
  }

But when i rewrite the function with this new version, I have a " comparison between pointer and integer" warning on the if statement:

void handler( int sig){
   printf("Signal recu\n");
    if( signal == SIGINT){
     click++;
     fprintf(stdout,"SIGINT received; Click = %d\n",click);
     if(click == N){
      fprintf(stdout,"Exiting with SIGINT\n");
       exit(0);
     }
   } else if(signal == SIGALRM){
      fprintf(stdout,"SIGALRM received\n"); 
      exit(0);
   } else if(signal == SIGTERM){
     fprintf(stdout,"SIGTERM received\n"); 
     exit(0);
   }

Can someone tell me where is the prob?

© Stack Overflow or respective owner

Related posts about c

    Related posts about signal