Matrix initialization error

Asked

Viewed 97 times

1

I don’t understand this error in the matrix.

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MAX 800

int main () {
     float ponto[MAX][MAX];
     float i, j, n, y, x, aux_st, aux_s;
     y = x = aux_st = aux_s = 0.0;
     n = MAX;

     for (i = 0; i < n; i++ ) {
           x =  - 2 + (i/n);
           for (j = 0; j < n; j++) {
                y = 2 - (j/n);
                aux_s = pow(x, 2) + pow(y, 2) - 1;
                aux_st = pow(aux_s, 3) - pow(x, 2)*pow(y, 3);
                if (aux_st == 0) ponto[i][j] = 246;
              }
      }
return 0;
}

Here is the result, containing the error:

prog.c: In function 'main':
prog.c:18:39: error: array subscript is not an integer
                 if (aux_st == 0) ponto[i][j] = 246;
                                       ^
prog.c:7:12: warning: variable 'ponto' set but not used [-Wunused-but-set-variable]
      float ponto[MAX][MAX];

1 answer

3


The error message is very clear: array indexes need to be integer. You’re using float! This is wrong.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.