error: expected primary-expression before ']' token
Hello folks, I can't find the problem in my code. It tells :
expected primary-expression before ']' token at line 24
thanks for your help ^^
#include <fstream>
#include <iostream>
#include <time.h>
# include <cmath>
/*‘n’ : retour à la ligne
– ‘t’ : tabulation
– ‘�’ : fin d’une chaîne (non imprimable)
*/
using namespace std;
int nombre(double i, double r);
void couleur(int V[],int size);
const int largeur = 1024;
const int hauteur = 768;
int main()
{
ofstream sortie("test.txt");
sortie<<"P3"<<' '<<'n'<<largeur<<' '<<hauteur<<'n'<<255<<'n';
int Chiffres[80];
couleur(Chiffres[],80);
int ***tab = new int **[hauteur];
for (int i = 0; i<hauteur; i++)
{
tab[i] = new int *[largeur];
for(int r=0;r<largeur;r++)
{
tab[i][r]= new int[3];
int coul=nombre(i,r);
for(int k=0;k<2;k++)
{
tab[i][r][k]=Chiffres[coul*3+k];
sortie <<tab[i][r][k]<<' ';
}
}
sortie <<'n';
}
sortie.close();
return 0;
}
int nombre(double i, double r)
{
double zim=0;
double zre=0;
double im = 1-((i*2)/768);
double re=((r*3)/1024) -2;
int n = 20;
double modulec=0;
int t =0;
for(; t<=n && modulec<=4;t++)
{
double temp=zre;
zre =(zre*zre) - (zim*zim) + re;
zim =(2*temp*zim) + im;
modulec = (zim*zim)+(zre*zre);
}
if (modulec <= 4)
return 0;
else
return t;
}
void couleur(int V[],int size)
{
char chaine[500];
ifstream entree("couleur.txt");
entree >> chaine;
while (!entree.eof())
{
entree >> chaine;
}
entree.close(); //ferme le fichier
int i = 0;
for (int j =0;j<60;j++)
{
int somme = 0;
while (chaine[i]!= 'n' && chaine [i]!='�' && chaine[i]!=' ')
{
somme = somme*10+(chaine[i]-'0');
}
V[j] = somme;
}
} |
couleur.txt:
0 0 0
41 41 41
25 25 112
0 0 128
0 0 139
0 0 205
61 89 171
65 105 225
72 118 255
100 149 237
30 144 255
79 148 205
92 172 238
99 184 255
135 206 250
176 226 255
202 225 255
240 248 255
252 252 252
255 255 255
Last edited on
couleur(Chiffres[],80);
change to
couleur(Chiffres,80);
Topic archived. No new replies allowed.