IDE: borland 5.01
k heb niet veel verstand van C of C++ wat betreft pointerd ed.
voor t programma heb ik de volgende functie geschreven:
t gaat fout op regel 12, dan komt er een error:
de code rond regel 12,14,15 heb ik elders gevonden op got voor t defineren van een multidimensional array.
wat doe ik precies fout?
k heb niet veel verstand van C of C++ wat betreft pointerd ed.
voor t programma heb ik de volgende functie geschreven:
t gaat fout op regel 12, dan komt er een error:
code:
1
2
3
4
| Thread stopped d:\cam.exe: Fault: access violation at 0x40146c: write of address 0x6c775a |
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| unsigned char ** avarage (unsigned char ** pixels, unsigned int width, unsigned int height) { /************************************************** * avarage returns the pixels avaraged * * the avarage of a pixel is taken in the area * * of 'size' around the pixel calculated * * Update, size is fixed as 1, calculates faster * **************************************************/ unsigned int i, x ,y; unsigned long totalofpixels; cout << "test1\n"; unsigned char ** avgpixels = new unsigned char * [width]; cout << "test2\n"; for (i = 0; i < width; i++) avgpixels[i] = new unsigned char[height]; for (y = 1; y < (height - 1); y++){ for (x = 1; x < (width - 1); x++){ totalofpixels = pixels[x-1][y-1]; totalofpixels += pixels[x][y-1]; totalofpixels += pixels[x+1][y-1]; totalofpixels += pixels[x-1][y]; totalofpixels += pixels[x][y]; totalofpixels += pixels[x+1][y]; totalofpixels += pixels[x-1][y+1]; totalofpixels += pixels[x][y+1]; totalofpixels += pixels[x+1][y+1]; avgpixels[x][y] = char (totalofpixels / 9); } } return avgpixels; } |
de code rond regel 12,14,15 heb ik elders gevonden op got voor t defineren van een multidimensional array.
wat doe ik precies fout?
[ Voor 3% gewijzigd door curry684 op 21-04-2004 14:54 ]
8<------------------------------------------------------------------------------------
Als ik zo door ga haal ik m'n dood niet. | ik hou van goeie muziek