Bonjour,
j'ai un problème avec mon code, lors de la compilation j'obtiens ce message d'erreur
error: subscripted value is neither array nor pointer nor vector
qui semble être causé par un tableau de variables global.
Voici le code:
main.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
| #include "SDLbot.c"
#include "wordGeneration.c"
int coordinates[100][100][10][3], locationX, locationY, coordinateX, coordinateY, type, displayDistance;
short numberElements, i;
int main()
{
initialisation();
/*
create command interpreter in individual thread
*/
wordGeneration();
/*
display word
SDLbot processes
SDLbot answers
word changes
loop
*/
return 0;
} |
SDLbot.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| extern int coordinates, locationX, locationY, coordinateX, coordinateY, displayDistance;
void initialisation()
{
locationX = 50;
locationY = 50;
coordinateX = 500;
coordinateY = 500;
displayDistance = 4;
}
int SDLbot()
{
return 0;
} |
wordGeneration.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 33 34 35 36
| #include <stdlib.h>
extern int coordinates, locationX, locationY, coordinateX, coordinateY, type, displayDistance, x, y;
short numberElements, i;
void wordGeneration()
{
x = locationX;
y = locationY;
x =- displayDistance;
y =- displayDistance;
//word generation
for(; x < locationX + displayDistance; x++)
{
for(; y < locationY + displayDistance; y++)
{
//contents chunk checking and filling
if(coordinates[x][y][0][2] == 0)
{
numberElements = rand() % 9;
for(i = 0; i < numberElements; i++)
{
coordinates[x][y][i][2] = rand() % 3;
coordinates[x][y][i][0] = rand() % 1000;
coordinates[x][y][i][1] = rand() % 1000;
}
coordinates[x][y][0][2] = 1;
}
}
}
} |
Le même message d'erreur m'est affiché pour le fichier wordGeneration.c à toutes les lignes contenant le tableau coordinates, je vois pas où se trouve le problème, quelqu'un pourrait m'aider ?
Partager