how to pass array element to an sub function?

i try to pass the add[W] to it's sub function (add) , but find out didn't succeed ~ ~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using namespace std;

# define happy__declspec (dllexport)

happy int __stdcall passV(bool Do_SL,double XP[12],double Support[3] ); // declare passV is exist in my dll
happy int __stdcall passV(bool Do_SL,double XP[12],double Support[3] )
{
  double add[12] ; 
  add[12] = 0  ,-4  , -5 , -6 ,-9 ,-12, -16,-31  ,-32  ,-34 ,-37  ;

   for (int w=0; w<=11;w++)
    { 
      if (XP[w]!=0)   continue;        
      open= Judge(Support[0],  add[w] , Do_SL,XP[w]) // see below function
}


1
2
3
4
5
string Judge(double Support,double add,double do_SL,double XP )
{ 
  cout<<add ;
  return("yes");
}
Last edited on
http://www.cplusplus.com/forum/general/11524/

Why did you keep the wrong array initialization?

BTW you are missing a brace and a semicolon
Last edited on
i am sorry that my brain is smoking and faint ~ ~^^
actually my code is not as little~ ~
--> i know what i wrong now, let me compile and debug it again~ ~


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using namespace std;

# define happy__declspec (dllexport)

happy int __stdcall passV(bool Do_SL,double XP[12],double Support[3] ); // declare passV is exist in my dll
happy int __stdcall passV(bool Do_SL,double XP[12],double Support[3] )
{
  double add[12] = { add[12] = 0  ,-4  , -5 , -6 ,-9 ,-12, -16,-31  ,-32  ,-34 ,-37   } ;

   for (int w=0; w<=11;w++)
    { 
      if (XP[w]!=0)   continue;        
      open= Judge(Support[0],  add[w] , Do_SL,XP[w]) // see below function
}


1
2
3
4
5
string Judge(double Support,double add,double do_SL,double XP )
{ 
  cout<<add ;
  return("yes");
}
Last edited on
line 8: double add[12] = { add[12] = 0 ,-4 , -5 , -6 ,-9 ,-12, -16,-31 ,-32 ,-34 ,-37 } ; remove that extra 'add[12]='
line 13: open= Judge(Support[0], add[w] , Do_SL,XP[w]) /*Where is the semicolon?*/
you are not closing the brace you opened at line 11
big thankyou

i have lots of careless mistake~ ~
Topic archived. No new replies allowed.