Hi!
I am vey new to C++ and I hope you can help me. Here is what I want to do: I want to create a new vector inside a block, under centain circumstances ("if ()"), with a length of "R" (R being a predefined variable), and I want it to be visible for the rest of the blocks.
Here is what I have managed to do:
int R;
cin>>R;
char p;
cin>>p;
if (p=='s' || p=='y')
longdouble *v2=newlongdouble[R];
{
if (*Idm=='e')
cout<<endl<<"Introduzca v2"<<endl;
elseif (*Idm=='i')
cout<<endl<<"Introduce v2"<<endl;
}
{
for (i=0; i<R; i++)
cin>>v2[i];
}
{
cout<<"v2: [ ";
for (i=0; i<R; i++)
cout<<v2[i]<<" ";
}
{
cout<<"]";
}
elseif (p=='n')
if (*Idm=='e')
cout<<endl<<"Listo"<<endl;
elseif (*Idm=='i')
cout<<endl<<"Ready"<<endl;
(With Idm being the language variable: i for English, e for Spanish)
Here is the problem: I want a *v2 variable to exist only if the user types y or s, also, I want *v2 to be used later in the program so it has to be visible outside the "if". Another problem: my complier (Turbo C++) tells me that the line "else if (p=='n') is misplaced, here I cant find what is wrong.
The function of this program would be a "vector calculator", allowing arithmetic operation such as vector sum or product. What I want to do is to create and store a new vector every time the user requires it. The vectors should be visible from other blocks to allow arithmetic operations with them. Is there a standard way to do this?.