I am preparing a program for 8bits bitwise rotation in which the input character will shift right by one bit everytime, eg.
when input "aaa", the result will be "-80 88 44"
And then I came out with the following and the result for inputing let say "aaa" will be
"-80 -80 -80"
and it waits for me to input another set of data, e.g. "aa"
and the result is "88 88"
,and then I input another set and the result is "44 44" and so on...
and I wonder how could I modify the program so that the shifting will be perfrom in one set of input and not with many set of inputs,
char ch,i;
printf("Please input character:");
for(i=1; i <=8;i++)
while((ch=getchar()) != '\n')
printf("%d ", ch=ch>>i|ch<<(8-i));
return (0);
thanks
I am thinking of adding another while loop in the last printf part but is not sure how could it be done.