How to store Ascii character set in an array using pointers

I'm trying to get a grasp on how to manage pointers effectively, and am trying to do a simple program that will store all the ascii characters into an array using pointers, and not array notation.
Someone told me that making the array an integer array would be the best method, but that makes no sense to me. I'm trying to do it with an array of characters at the moment.

The way I have my code now, I'm sure that I am just putting an integer value into a character array. I want to do something like (char(i)) to convert it properly into the character I want.

int main( int ac, char ** av)
{
int i,pause;
char AsciiArray [255];
int* pAsciiArray = AsciiArray;

for (i=0; i<256; i++)
{
*pAsciiArray = (char(i));
pAsciiArray++;
}

As you can see I'm pretty clueless about pointers.. Any helpful advice would be muchly appreciated..
Change pAsciiArray to a char* otherwise it will increase its position by sizeof(int) instead of sizeof(char). You should also make AsciiArray to have 256 as size or the character 255 would cause an error
A couple things:
1. A char is an integer, there's nothing magical about them. You can do char a=35; and it's correct. Always remember that computers can only handle numbers.
2. This is a misuse of arrays. If you have an array where array[0]==0, array[1]==1, ..., array[n]==n, you're doing something wrong. Arrays are used to link a numerical index to a value, so that access to the value can be performed in constant time. When the index and the value are always the same, the array becomes pointless. It's like asking "what color was Napoleon's white horse".
Topic archived. No new replies allowed.