Compil error in Code C
Posted: Mon Dec 03, 2007 2:10 am
I am beginner in language C
I create a function to translate string (ex:"10110") in a integer ,but compilation is on error in the first line:
bintodec.c(1): error: missing semicolon
bintodec.c(1): error: failure
here is by function :
int Bintodec (char* IN)
{
char I;
char X;
int RESULT;
char LEN;
char DIG;
char P[10];
char DIGIT;
I = 0;
X = 0;
RESULT = 0;
LEN = 0;
DIG = 0;
LEN = Length$(IN);
X = LEN - 1;
P[0] = 1;
P[1] = 2;
P[2] = 4;
P[3] = 8;
P[4] = 16;
P[5] = 32;
P[6] = 64;
P[7] = 128;
while( I < LEN )
{
DIGIT = Mid (IN,X,1);
DIG = Asc(DIGIT);
DIG = DIG - 48;
RESULT = RESULT + ( DIG * P );
I = I + 1;
X = X - 1;
}
return (RESULT);
}
Can someone help me ?
I create a function to translate string (ex:"10110") in a integer ,but compilation is on error in the first line:
bintodec.c(1): error: missing semicolon
bintodec.c(1): error: failure
here is by function :
int Bintodec (char* IN)
{
char I;
char X;
int RESULT;
char LEN;
char DIG;
char P[10];
char DIGIT;
I = 0;
X = 0;
RESULT = 0;
LEN = 0;
DIG = 0;
LEN = Length$(IN);
X = LEN - 1;
P[0] = 1;
P[1] = 2;
P[2] = 4;
P[3] = 8;
P[4] = 16;
P[5] = 32;
P[6] = 64;
P[7] = 128;
while( I < LEN )
{
DIGIT = Mid (IN,X,1);
DIG = Asc(DIGIT);
DIG = DIG - 48;
RESULT = RESULT + ( DIG * P );
I = I + 1;
X = X - 1;
}
return (RESULT);
}
Can someone help me ?