Help me with syntax error in C++ code

Status
Not open for further replies.

fatma1000

Banned
Joined
Apr 30, 2006
Messages
147
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
eygpt
Activity points
0
help11 c++

whin i run my program i have 102 error most of them like this

F:\prog2\test.cpp(37) : error C2143: syntax error : missing ']' before ';'
F:\prog2\test.cpp(37) : error C2143: syntax error : missing ';' before ']'

the line these two errors point is

double EX[ZMAX];

please tell me what can i do?

regards
 

help11 c++

funny
is ZMAX declared correctly?
#include <stdlib.h>
#include <iostream>

#define ZMAX 30
using namespace std;
int main()
{
double x[ZMAX];
return 0;
}
this compiled with out a hitch.
 

Re: help11 c++

so thanks but i don not understand what is wrong so

i will give you this part of my program to tell me what is wrong


#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
#include <mbstring.h>

#define ZMAX 15000;
#define TMAX 35001
#define d 8
// define natural parameters and material parameters
double c=2.99795645e8;
double pi=3.14159265358979312;
double mu_0=12.566370e-7;
double eps_0=8.854e-12;
double B1=1.0995/3;
double B2=0.9/3;
double omega01=1.885e16/6;
double omega02=2.094e14*4;
double delta=2e9;
double Ki_3=0;
double alp=0.7;
double tau_1=12.2e-15;
double tau_2=32e-15;
//////////////////////////////////
//define pulse parameters
double AMP=1;
double STW=14.6e-15;
double CCW=4.3e-15;
///////////////////////////////
// define the steps per carrier frequency period
double GPP=40;
////////////////////////
//stability factor
double t_dm_discr=0.5;
///////////////////////
double EX[ZMAX];
double DX[ZMAX];
double DX1[ZMAX];
double HY[ZMAX];
double BY[ZMAX];
double BY1[ZMAX];
double F1_2[ZMAX];
double F1_1[ZMAX];
double F1_0[ZMAX];
double F2_2[ZMAX];
double F2_1[ZMAX];
double F2_0[ZMAX];
double G_2[ZMAX];
double G_1[ZMAX];
double G_0[ZMAX];
double caex[ZMAX];
double cbex[ZMAX];
double caby[ZMAX];
double cbby[ZMAX];
double sig[ZMAX];
double sigs[ZMAX];
double sigmas[d];
double sigma[d];




///////////////////////

void main()
{
int t=0,z=0,i=0;
double dt,dz,N,grpv;
double EX_p,EX_pp,diff_iter;
FILE *fp1;
FILE *fp2;
.................
..................
.......................




regards
 

Re: help11 c++

the problem which i can see is

u should declare values which r in fraction like 0.5 as float variables
check it u declared it double
 

Re: help11 c++

i found the error it is in

#define ZMAX 15000;

this ";" is the error

thanks
 

help11 c++

Yip that is def the eroor. no ; after a #define
common mistake. I ussually do it when writing a prog.
I even somtimes put a ; after comments in my code.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…