マシンの問題のためにいくつかのコードを処理しています。私たちはちょうどポインタなどで作業を始めました。だからどこが間違っているのかよく分かりません。デバッグを実行すると、次のような行が表示されます。for(i = 0; i < * y; i ++)エラーをスローしていますが、間違っていても間違っていると確信しています(j = 0; j < * ; j ++)スペース。どんな助けでも大歓迎です。セグメンテーションエラーを取得する
int readImage(char* fileName,
int image[MAX_IMAGE_SIZE][MAX_IMAGE_SIZE][NUM_CHANNELS],
int* x,
int* y,
int* max)
{
/* Variable declarations*/
int i=0;
int j=0;
int k=0;
int num=0;
char c;
/* Opens file, skips first line*/
FILE *input=fopen(fileName, "r");
if(!input)
return -1;
do
c=getc(input);
while(c!='\n');
/*Saves the x and y components into a variable */
fscanf(input,"%d",&x);
fscanf(input,"%d",&y);
fscanf(input,"%d",&max);
/*Cycles through file, reading it into the array */
for(i=0; i<*y;i++)
{
for(j=0;j<*x;j++)
{
for(k=0;k<NUM_CHANNELS; k++)
{
/*Takes input */
fscanf(input, "%d",&num);
/*Stores into the array in the form of array[x][y][color] */
image[j][i][k]=num;
}
}
}
/*Closes input */
fclose(input);
return 0;
}
これでは十分ではありません。残りのコードを参照する必要があります。 – jwodder