i am a neb and i really need help on this whe i type in charater A the program gives me 66, which is wrong it should be 65.
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void getBinary(char ch);
/*int getBit(char ch,int x) ;
void changeBit(char ch, int x);
*/
int main(int argc, char* argv[])
{
char a;
printf("Enter a character");
scanf("%c",&a);
getBinary(a);
//printf("the new character after the bit change is %i",ch);
getch();
return 0;
}
void getBinary(char ch)
{
int mask = 128;
int i;
printf("\nThe binary value of %c is:");
for (i=0; i <=8; i++)
{
if ((ch &mask)!=0)
printf("1");
else
printf("0");
ch=ch<<1;
}
}
/* int getBit(char ch,int x)
{
}
void changeBit(char ch, int x)
{
}
*/