tom_hanks
Full Member level 5
hi,
why is this code is not working?
Bin to Dec convertor....
------------------------------------------------------------------------------------------
int Bin2Dek(long * string)
{
unsigned long dioda[8];
unsigned int broj = 0;
dioda[8] = *string;
if(dioda[0] == 1) broj += 1;
if(dioda[1] == 1) broj += 2;
if(dioda[2] == 1) broj += 4;
if(dioda[3] == 1) broj += 8;
if(dioda[4] == 1) broj += 16;
if(dioda[5] == 1) broj += 32;
if(dioda[6] == 1) broj += 64;
if(dioda[7] == 1) broj += 128;
return broj;
}
why is this code is not working?
Bin to Dec convertor....
------------------------------------------------------------------------------------------
int Bin2Dek(long * string)
{
unsigned long dioda[8];
unsigned int broj = 0;
dioda[8] = *string;
if(dioda[0] == 1) broj += 1;
if(dioda[1] == 1) broj += 2;
if(dioda[2] == 1) broj += 4;
if(dioda[3] == 1) broj += 8;
if(dioda[4] == 1) broj += 16;
if(dioda[5] == 1) broj += 32;
if(dioda[6] == 1) broj += 64;
if(dioda[7] == 1) broj += 128;
return broj;
}