I am trying to find index of 1s in my string to get Power of Two. Dont know how to deal with pointer. Any help over this.
int main()
{ int i,j,k;
char inbit[20], count[16];
char fdata[32],coeff[17],signb[17];
printf("Enter X(n) data file with extension: ");
scanf("%s",inbit);
//strcpy(inbit,flr);
printf(" Data in file :%s\n", flr(inbit));
//printf(" Hex conversion : %s\n", hexc(flr(inbit)));
strcpy(fdata,hexc(flr(inbit)));
printf(" Hex conversion : %s\n", fdata);
memcpy(signb, fdata, 16);
memcpy(coeff, fdata +16, 16);
signb[16] = '\0';
coeff[16] = '\0';
printf(" part1 signbit : %s\n", signb);
printf(" part2 valuebit : %s\n", coeff);
for (i=0;i<16;i++)
{j=0;
if (coeff[i] =1)
{count[j]=i;
j++;}
}
printf("%s\n",count);
return (0);
} Undoubtedly output is null because coeff[i] provides location instead of value as being a pointer. Any help ?
Aucun commentaire:
Enregistrer un commentaire