Hi, My code does an xor operation for each 8 bits and stores the value in an integer variable. I get the text in char by using a while loop then I do the xor operation inside the loop for each 8 bits and store it to an integer variable. This program works perfectly for 8 bits however if it is a 16 bit code I doesn't work. I made an counter variable to check each 8 bits I reset the counter when it is 9. This should work I tried everything. If I enter more than 8 bits the integer variable that I use to store becomes a big negative integer. Sorry for the bad english. I appriciate any help and tips.









Code:
      if (base==2)                        /*Start of the base 2 text decode*/
        {
            printf("Please enter the text to decode:");
            scanf(" %c", &text);
            while (text!=LF)                             /* This while loops takes the text from the user*/
            {

                if( (text!='1') && (text!='0'))
                {
                    printf("The text is not in base 2!"); /* This if statement gives error if the text is not in base 2 and stops the program*/
                    menu_selection=3;
                    break;
                }
                /* This huge if else chain does the xor operation and stores it in an integer value*/
                if (counter==1)
                {
                    if(code1!=text)
                    {
                       nxor=nxor+1;
                       nxor=nxor*10;
                    }
                    else if (code1==text)
                    {
                       nxor=nxor+0;
                       nxor=nxor*10;
                    }
                }
                else if (counter==2)
                {
                    if(code2!=text)
                    {
                       nxor=nxor+1;
                       nxor=nxor*10;
                    }
                    else if(code2==text)
                    {
                       nxor=nxor+0;
                       nxor=nxor*10;
                    }
                }
                else if (counter==3)
                {
                    if(code3!=text)
                    {
                       nxor=nxor+1;
                       nxor=nxor*10;
                    }
                    else if (code3==text)
                    {
                       nxor=nxor+0;
                       nxor=nxor*10;
                    }
                }
                else if (counter==4)
                {
                    if(code4!=text)
                    {
                       nxor=nxor+1;
                       nxor=nxor*10;
                    }
                    else if(code4==text)
                    {
                       nxor=nxor+0;
                       nxor=nxor*10;
                    }
                }
                else if (counter==5)
                {
                    if(code5!=text)
                    {
                       nxor=nxor+1;
                       nxor=nxor*10;
                    }
                    else if(code5==text)
                    {
                       nxor=nxor+0;
                       nxor=nxor*10;
                    }
                }
                else if (counter==6)
                {
                    if(code6!=text)
                    {
                       nxor=nxor+1;
                       nxor=nxor*10;
                    }
                    else if(code6==text)
                    {
                       nxor=nxor+0;
                       nxor=nxor*10;
                    }
                }
                else if (counter==7)
                {
                    if (code7!=text)
                    {
                       nxor=nxor+1;
                       nxor=nxor*10;
                    }
                    else if (code7==text)
                    {
                       nxor=nxor+0;
                       nxor=nxor*10;
                    }
                }
                else if (counter==8)
                {
                    if (code8!=text)
                    {
                       nxor=nxor+1;
                       nxor=nxor*10;
                    }
                    else if (code8==text)
                    {
                       nxor=nxor+0;
                       nxor=nxor*10;
                    }
                }
                scanf("%c", &text);
                counter++;
                if (counter==9)
                    counter=1;
                totalcounter=totalcounter+1;
            }