C,What is the difference between unsigned int(a)^unsigned int(b) and unsigned int(a^b)? -


in test platform , write program bellow:

int a, b; scanf_s("%d%d",&a,&b); unsigned int c = a^b;//this can not pass unsigned int c = unsigned int(a)^unsigned int(b) //this can pass int cnt = 0; while (c){     cnt++;     c = c&(c-1); } printf("%d\n",cnt); 

thanks,

there serious syntax error in program doubt compiled try following program , should work fine.

following issues there in code.

  • c declared twice
  • casting of int unsigned int had mistake

    int main() {    int a, b;   scanf_s("%d%d",&a,&b);   unsigned int c = a^b;//this can not pass   c = (unsigned int)a^( unsigned int )b;//this can pass   int cnt = 0;   while (c){       cnt++;       c = c&(c-1);   }   printf("%d\n",cnt);    return 0;  } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -