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[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

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


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

in other hand
and so on

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;

if you want to print the char :D

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

if you have still problem i am online in gtalk

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.

This article has been dead for over six months. Start a new discussion instead.