Compil error in Code C

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
MIKE_31
Posts: 15
Joined: Wed Aug 08, 2007 12:11 pm
Location: FRANCE
Contact:

Compil error in Code C

Post by MIKE_31 »

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 ?

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

Hello,

Are you using Flowcode? If so, where is this code?

Also, the line LEN = Length$(IN); will not work because there is no in-built Length$ function in C.

MIKE_31
Posts: 15
Joined: Wed Aug 08, 2007 12:11 pm
Location: FRANCE
Contact:

Post by MIKE_31 »

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

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

The edits you will need to make are:

1) Put the following code into the "definitions" box of the "supplementary code" window:

Code: Select all

int Bintodec(char* IN);
#include "bintodec.c"
2) In a C icon within your program, call the function like this:

Code: Select all

FCV_B = Bintodec(FCV_DATA);
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:

Code: Select all

LEN = Length$(IN);

DIGIT = Mid (IN,X,1);
DIG = Asc(DIGIT);
You will need to write your own code for these functions.

Post Reply