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 ?
Compil error in Code C
Hello,
Yes a use Flowcode V3 Professionnal,
This code is in a file bintodec.c ,I added
char BIN_TO_DEC(char IN); to the definition and
#include "bintodec.c" in the suppementary code.
I went to use this code like a function in My main program like:
FCV_B = bintodec(FCV_data); (data = string and B as integer)
Michel
Yes a use Flowcode V3 Professionnal,
This code is in a file bintodec.c ,I added
char BIN_TO_DEC(char IN); to the definition and
#include "bintodec.c" in the suppementary code.
I went to use this code like a function in My main program like:
FCV_B = bintodec(FCV_data); (data = string and B as integer)
Michel
- Steve
- Matrix Staff
- Posts: 3424
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
The edits you will need to make are:
1) Put the following code into the "definitions" box of the "supplementary code" window:
2) In a C icon within your program, call the function like this:
Note that C is case-sensitive, so you need to be exact.
For some reason, the compiler is refusing to accept the array variable "P" in your C file - change this to "PP" and it is ok.
Also, there are 3 lines in your C code that will not compile:
You will need to write your own code for these functions.
1) Put the following code into the "definitions" box of the "supplementary code" window:
Code: Select all
int Bintodec(char* IN);
#include "bintodec.c"
Code: Select all
FCV_B = Bintodec(FCV_DATA);
For some reason, the compiler is refusing to accept the array variable "P" in your C file - change this to "PP" and it is ok.
Also, there are 3 lines in your C code that will not compile:
Code: Select all
LEN = Length$(IN);
DIGIT = Mid (IN,X,1);
DIG = Asc(DIGIT);