here i have used a char * and have malloc ed an arbitrary number of bytes to it. now what i need to do is fill all the 5 bytes with 0(that is taken care of by the *ch=0 , no problem). now after this i or ch with 1 and shift it left 1 time. if u see the output at this time u will notice that not only is the 2nd bit (from right) is set to 1 but also another bit in the 5th byte. how do u correct this? or is such thing not possible. the code is like this.can be run in TC. thanx in advance.
Code:
#include<stdio.h>
#include<conio.h>
#include<alloc.h>

void showbits(char *n,int b)
{
	int i,k;
	int *mask;
	mask=(int *)malloc(b);
	int count=0;
	for(i=(8*b)-1;i>=0;i--)
	{
		*mask=1<<i;
		k=*n & *mask;
		k==0 ? printf("0"):printf("1");
		count++;
	}
	printf("\n%d\n",count);
}

int main()
{
//	clrscr();
	char *ch;
	ch=(char *)malloc(5);
	*ch=0;
	for(int i=0;i<8;i++)
	{
		*ch=*ch | 1;
		*ch=*ch<<1;
	}
 	*ch=*ch | 1;
	*ch=*ch<<1;
	showbits(ch,5);
	getch();
	return 0;
}