cpp(1142) : error C2181: illegal else without matching if
I've the following error:
cpp(1142) : error C2181: illegal else without matching if
Would you please help in this one ?
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
for(i=0;i<npixels;i++)
{
if(val < my.at(i))
{
grid<<my.at(i)/24<<endl;
t_final=my.at(i);
//t_final=Tau/c , c=2,4,6
//ri=sqrt(_k*t_final*24/(948*ct*mio));
//Area.push_back(dx[0]*dy[0]*dz[0]*phi*(i));
Area.push_back(2*dx[0]*dy[0]*t_final*sqrt(_k1/(3792.0*ct*mio*phi)));
//Area.push_back(4*pai*h*(t_final*_k1/(948*ct*mio)));
//tmp=phi*Area[jj]*h;
//tmp=Area[i];
Vp.push_back(Area[jj]);
//-----------------------------//
tc=1000*(dx[0]*dx[0]/4*ct*mio*phi/_k1);
double finite_volume =4*pai*h*tc*_k1/(948*ct*mio);
//for(i=0;i<npixels-1;i++)
// {
if (i<=tc)
{
tmp=4*pai*h*24*i*_k1/(948*ct*mio);
else
tmp=4*pai*h*tc*_k1/(948*ct*mio)+ 0.5*(Vp[i+1]-Vp[i]);
Vp1.push_back(tmp);
}
//----------------------------//
//cout<<"T_final - > "<<t_final<<" tc->" <<tc<<" Vp->"<<tmp<<endl;
//getchar();
//tmp=my.at(i);
//tmp=0.25*(pow(tmp,2));
t_.push_back(my.at(i));
ri=sqrt(_k1*24*(0.25*t_final*t_final)/(948*ct*mio*phi));
r_i<<""<<ri<<endl;
//ri.push_back(sqrt(Area[jj]/pai));
//Vp.push_back(2*ri*dx[0]*dy[0]);
//r_i<<""<<ri[jj]<<endl;
//----------------qw from rinv----------Logx=Lnx/Ln10=Ln x/2.3
_qw<<0.00708*dpw*_k1*h/(mio*(log(ri/rw)-0.5))<<endl;
//Pw= Pi-(162.6*qw*mio)/(_k1*h)*(log10(_k1*t_final/(ct*mio*phi*rw*rw))-3.23);
//Pw=(Pi-delta_p)/(0.00708*dpw*_k1*h/(mio*(log(ri/rw)-0.5)))*qw;
//_qw<<0.00708*dpw*_k1*h/mio*1/(1/ri[i]-1/ri[i+1]+(ri[i]-ri[i+1])/(7032.84*7032.84))<<endl;
//qw=0.00708*dpw*_k1*h/(mio*(2.303*log(ri[i]/rw)-0.5));
//----------------qw from Vp(t)--------------
//qw=0.001127*dpw*_k*phi/(mio*(A[i+1]-A[i]))
val=my.at(i);
jj++;
}
}
|
The error is in this part:
if (i<=tc)
{
tmp=4*pai*h*24*i*_k1/(948*ct*mio);
else
tmp=4*pai*h*tc*_k1/(948*ct*mio)+ 0.5*(Vp[i+1]-Vp[i]);
Vp1.push_back(tmp);
}
That's not the proper syntax for if-else. It should look more like this:
1 2 3 4 5 6 7 8
|
if ( condition )
{
//code to execute if condition is true
}
else
{
//code to execute if condition is false
}
|
Note the placement of the curly brackets
{ }
THANKS
Topic archived. No new replies allowed.