Computing.Net > Forums > Programming > C++ array question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C++ array question

Reply to Message Icon

Name: jim
Date: October 24, 2002 at 01:31:38 Pacific
OS: winxp
CPU/Ram: 1700+,256
Comment:

hi!i m having a problem with an array i m using inside a double loop to store some results,but im a bit stuck on how i ll use this array in another function.
i get that psd (this is the array) isnt declared.I know that psd is declared locally inside the loop at the moment,but as i said i m a bit stuck on how to proceed.It has to be something easy that i cant see i guess...
thank you for any suggestions

int x,y;
for (x=0;x<128;x++)

{
for (y=0;y<96;y++)

{ int pixelofpsb,pixelofpsc;
pixelofpsb= get_pixel2(x,y);
pixelofpsc= get_pixel3(x,y);

int psd[128][96];
psd[x][y] = (pixelofpsb)^(pixelofpsc);

}

}


scanleft2(Coords[0].x,Coords[0].y,psd);
//here is where i need to use psd.scanleft scans the pixels of the image until it finds a black pixel

-------------
int CMainFrame::scanleft2(int &x,int &y,int *Pic)
{
for (x=0;x<128;x++)
{
for (y=0;y<96;y++)
{
if (ChunkyGetPixel2(x,y,5,Pic) == BLACK)
return 1;
}
}
return 0;
}



Sponsored Link
Ads by Google

Response Number 1
Name: Marcus
Date: October 24, 2002 at 06:08:00 Pacific
Reply:

Hi Jim!

The problem is that the array is declared within the scope of the inner for-loop. Outside the for loop it will not be accessable.

Decare it at the top of the function you intend to use it and then you can access it throughout that function and also be able to pass it to your other function.

/ Marcus

Ps. Fix up those variable name.. =)


0
Reply to Message Icon

Related Posts

See More


javascript value for PHP ... Visual Basic for Applicat...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C++ array question

c++ arrays question www.computing.net/answers/programming/c-arrays-question/13122.html

C++ Array Pointer Parameter www.computing.net/answers/programming/c-array-pointer-parameter/6482.html

Perl array question www.computing.net/answers/programming/perl-array-question/4352.html