How do I insert a character into a number array? Is it possible? a and b are constants.

for(int i = 0; i <n; i++)
	{
		pointer[i] = new int[n];
    }
      for(int i=0;i<n;i++)
	  {
		for(int j=0;j<n;j++)
		{
			pointer[i][j]=1;/
			pointer[a][b]="*";	//<----	
        }
      }

you can't insert strings into int arrays, but you can insert a character pointer[a][b] = '*'; <<< single quotes, not double quotes

Character can be inserted to an no. eg. int.
I that situation the char ASCII code is copied to the int.
like for example
A=65
a=97

As you program look confusing i'm sorry i can't tell you more.
But if you are really up to linking pointer and array this might come handy.

Internally, address are resolve like this

ARRAY | POINTER

s[0]=*(s+0) or *s or *(s)
s[1]=*(s+1)
s[2]=*(s+2)
and so on..


in other hand
s[0][0]=*(s[0]+0)=*(*(s+0))=**s
s[0][1]=*(s[0]+1)=*(*(s+1))
.
s[1][2]=*(s[1]+2)=*(*(s+1)+2)
.
s[3][4]=*(s[3]+4)=*(*(s+3)+4)
and so on

When I insert a char like '*' I get a number in the output.

When I insert a char like '*' I get a number in the output.

That is obvious what do you expect..
the ASCII Code for * is 42

you can also do something like
int c=42;
cout<<(char)c;

if you want to print the char :D

I dont want to cout the char I want pointer[a] to be the char.

I dont want to cout the char I want pointer[a] to be the char.

I don't really understand the question but...

let p be the pointer
int a;
int *p=&a; //stores the the address of a
cout<<&p; //revels the address of P
cout<<p; //revels the address it stores
cout<<*p; //revels the information stored in the pointed address that is value of a

now if you want to show the char of a then
cout<<(char)*p;

if you have still problem i am online in gtalk the.nube@gmail.com

I dont want to cout the char I want pointer[a] to be the char.

Then declare pointer to be an array of characters, not an array of integers.

Ya I agree Arrary of char should satisfy him..
:d

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.