Мне нужна помощь, пожалуйста;это пример кода:
#include <stdio.h>
const int n = 4;
const int m = 4;
void display(int arr[n][m]){
for(int i=0; i<n; i++) {
for(int j=0;j<m;j++) {
printf("%d ", arr[i][j]);
}
printf("\n");
}
}
int *constrast(int arr[n][m])
{
int temp[n][m];
int max = 25;
int min = 10;
int uBound = 255;
int lBound = 0;
for(int i=0; i<n; i++) {
for(int j=0;j<m;j++) {
temp[i][j] = ((arr[i][j] - max) *((int)(uBound-lBound)/(max-min))+uBound;
}
}
return temp;
}
int main()
{
int disp[4][4] = {
{10, 11, 12, 13},
{14, 15, 16, 17},
{18, 19, 20, 21},
{22, 23, 24, 25}
};
printf("Image Before Stretching:\n");
display(disp);
printf("Image After Stretching:\n");
display(constrast(disp));
return 0;
}
Это сообщение об ошибке, которое я получаю после попытки компиляции:
contrast.c: In function ‘display’:
contrast.c:6:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int i=0; i<n; i++) {
^
contrast.c:6:4: note: use option -std=c99 or -std=gnu99 to compile your code
contrast.c:7:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int j=0;j<m;j++) {
^
contrast.c: In function ‘constrast’:
contrast.c:21:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int i=0; i<n; i++) {
^
contrast.c:22:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int j=0;j<m;j++) {
^
contrast.c:23:82: error: expected ‘)’ before ‘;’ token
temp[i][j] = ((arr[i][j] - max) *((int)(uBound-lBound)/(max-min))+uBound;
^
contrast.c:24:7: error: expected ‘;’ before ‘}’ token
}
^
contrast.c:28:4: warning: return from incompatible pointer type [enabled by default]
return temp;
^
contrast.c:28:4: warning: function returns address of local variable [-Wreturn-local-addr]
contrast.c: In function ‘main’:
contrast.c:44:1: warning: passing argument 1 of ‘display’ from incompatible pointer type [enabled by default]
display(constrast(disp));
^
contrast.c:4:6: note: expected ‘int (*)[(sizetype)m]’ but argument is of type ‘int *’
void display(int arr[n][m]){
^