|
Page 1 of 1
|
[ 3 posts ] |
|
Function with array parameter and class
| Author |
Message |
|
swonder
Rookie
Joined: Sat Mar 14, 2009 3:53 am Posts: 6
|
 Function with array parameter and class
When i declare a function with array parameter and class. I always get error. Part of the codes is a as below,
struct typedef { int a; int b; } data;
data call(int sh[], data temp);
task main() { data one; one.a = 1; one.b = 1; int sh[5]; sh[4]....[0] = 1; //short form one = call(sh, one); }
data call(int h[], data temp2) { ............ return temp2; }
How to declare function with array parameter and class correctly? Help please.
|
| Sat Mar 14, 2009 4:08 am |
|
 |
|
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Function with array parameter and class
RobotC does not support passing arrays to functions. I suggest you use a struct of some kind. I used the following kludge: This seems to work. Not sure if returning a struct from a function works. I wouldn't bet on it. Regards, Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sat Mar 14, 2009 5:58 am |
|
 |
|
Ford Prefect
Guru
Joined: Sat Mar 01, 2008 12:52 pm Posts: 1030
|
 Re: Function with array parameter and class
... and as far as I know, in ROBOTC this aint working never: you have to fill in the size of h[], ROBOTC didn't work when I once tried to do sth like this. ROBOTC is not C, its hardly "not quite C" and - as Mightor said - bugged like hell... 
_________________ regards, HaWe aka Ford #define S sqrt(t+2*i*i)<2 #define F(a,b) for(a=0;a<b;++a) float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}
|
| Sat Mar 14, 2009 9:04 am |
|
|
|
Page 1 of 1
|
[ 3 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|