[try Beta version]
Not logged in

 
question - pinter.array

Aug 10, 2015 at 7:57pm
hello guys;
would any of u tell me what bug does this have? ma compiler can't continue after the part "Number 1 :". :(

[
int *p,*w;

int in(int x[3],int y[3])
{
int i=0;
do
{cout<<"Number "<<i+1<<" : ";
cin>>x[i];
i++;}while(i<3);

cout<<endl;

for(int j=0;j<3;j++)
{cout<<"Number "<<j+1<<" : ";
cin>>y[j];}

p=x;
w=y;
return y[3],x[3];
}

and then in function main i call :
in(p,w);
]
Aug 10, 2015 at 8:02pm
Could you please post all your code and put it in code tags
Aug 10, 2015 at 8:15pm
How to use tags: http://www.cplusplus.com/articles/z13hAqkS/

int* and int[] are not the same.
Your function has a return type of int, which works with return y[3],x[3];, but it does not do whatever it is that you probably intended for it to do.
return y[3],x[3]; will return the value of the thirdfourth integer in the array called x.
Some information on how the comma operator works: http://stackoverflow.com/questions/54142/how-does-the-comma-operator-work
x[3] when used in an expression is the thirdfourth value in the array called x, but when used in a function prototype it refers to an array that has 3 elements.

Now on to your actual question
would any of u tell me what bug does this have? ma compiler can't continue after the part "Number 1 :". :(

Would you please post the exact error your compiler reports? What compiler are you using? Is your entire code short enough to post here?
Last edited on Aug 16, 2015 at 2:33am
Aug 10, 2015 at 8:18pm
Just a quick question: did you allocate memory for p and w arrays?
Aug 14, 2015 at 10:45am
@miinipaa
yes actually they are global and are NULL by the time i define em.
Aug 14, 2015 at 10:57am
@kevin
thanks
i really needed that!
Aug 14, 2015 at 2:31pm
x[3] when used in an expression is the third value in the array called x

Actually, it's the 4th value, to be accurate.

Edit: I'm sure you know that, but I just wanted to make sure the OP isn't confused.
Last edited on Aug 14, 2015 at 2:32pm
Aug 16, 2015 at 2:35am
Thanks MikeyBoy, I meant fourth not third.
Topic archived. No new replies allowed.