Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[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
Full Member level 1
Joined
Dec 14, 2010
Messages
98
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Cairo, Egypt, Egypt
Activity points
2,001
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
Advanced Member level 7
Joined
Nov 7, 2006
Messages
9,505
Helped
1,186
Reputation
2,391
Reaction score
1,186
Trophy points
1,403
Location
Brazil
Activity points
55,135
I´m still curious about this implementation :

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

+++
 

alexan_e

Administrator
Advanced Member level 7
Joined
Mar 16, 2008
Messages
11,888
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,371
finally it work ok

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

I´m still curious about this implementation :
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
Full Member level 1
Joined
Dec 14, 2010
Messages
98
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Cairo, Egypt, Egypt
Activity points
2,001
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top