Continue to Site

# [SOLVED]when i use array with with function the compiler assign as an error in the data type

Status
Not open for further replies.

#### mahm150

##### Full Member level 1
it work ok and give the coorrect

---------- Post added at 20:13 ---------- Previous post was at 19:14 ----------

void arrange_message(unsigned char*,unsigned char data_order);
**************************************************
arrange_message(THREE,1);
**********************************
void arrange_message(unsigned char data_wrtn[],unsigned char data_order)
{
unsigned char p;
if(data_order==1)
{
for(p=0;p<=15;p++)
{
temp1[p]= data_wrtn[p];
}
}
}
*****************************************
finally it work ok

#### andre_luis

##### Super Moderator
Staff member

void arrange_message(unsigned char*,unsigned char data_order);
There is not missing the 1rst input variable ?

+++

#### alexan_e

finally it work ok

I don't understand, why wasn't it working the first time and it woks now?

There is not missing the 1rst input variable ?

I have no idea how this works because I have never used this way.

What I usually do is

Code C - [expand]1
2
3
4
5
6
7
8
9
10
11
void my_function (char *myarray_p)
{
// and then read the array using
some_variable = *myarray_p++; // assign the value pointed by p, and then increment the address p
some_other_variable = *myarray_p++; // assign the value pointed by p, and then increment the address p

//or it can also be done with a loop.
}

//To call the function I send the address of the array
my_function(myarray);

Alex

#### mahm150

##### Full Member level 1
like you i don't know why it isn't work first and work last
i think that first i write that temp1[p]= & data_wrtn[p]; and i do understand why we use the * pointer and what is the meaning of use it with array
i understand that we use use pointer to point to the first parameter in array

---------- Post added at 22:37 ---------- Previous post was at 22:35 ----------

for andre_teprom the function it work and there is no syntax error

Status
Not open for further replies.