converting frm string to char and using pointer

Hi,
I am writing a code that in the middle I have a problem in converting a string to char. I need to get a character from a string and use that specific character in a Ascii-art produced shape.
Actullay I have a string input from getline that I extracted one character of the string with these lines of code:
( let assume that the input is 'pen x' and extracting x is wanted)
getline(cin,command);
int leng= command.length();
string *strg= new string[leng+3];
for(int i=0;i<=leng+1;i++)
{
strg[0]=' ';
strg[i+1]=command[i];
strg[leng+1]=' ';
}
// for(int i=0;i<=leng+3;i++)
// cout<<strg[i]<<"-";
int *pos = new int[leng+1];
int j=0;
for(int i=0;i<=leng+1;i++)
{
if(strg[i]==" ")
{
pos[j]=i;
j++;
}
}
int k=2;
string p = command.substr(pos[k-1],(pos[k]-pos[k-1]-1));



Now I have two problem:
The first problem is that I need to pass p as a character (and not a char *, just char) to a created member function of a class in order for using that character to draw a rectangle. ( I have tried c_str function of the string library, although I am not sure that I used it correctly.)

void mycommands::rectangle(int l , int t , int r , int b, char ch)
{
for (int i=0;i<Mcol;i++)
{
if((i>t)&&(i<b))
{
for(int j=0;j<Mrow;j++)
{
if(!((j<l)||(j>r)))
array[i][j]=ch;
}
}
}


}

Also the second problem is that the mentioned varible 'p' is derived as a local variable in an if-statement. but I need to use it in another if statment body and I need a pointer for this exchange of data between the two if-statement. But I was not successful to do this pointing.


can anybody help me????
Topic archived. No new replies allowed.