Pointers are the bane of many a programmer wannabe
As far as the CPU is concerned, a pointer (to anything) is an integer like any other integer, except that it is used only to keep track of where something else is. An index into that huge array we call memory in normal speech.
pai() meaning PrintAsInt() - how to define this will depend on wether we are working in C or in C++.
Code:
int main() {
char* alphabet = "abcde";
int i=3;
int* ip=&i; // ip = address_of i
pai(alphabet); // A number for a position in memory.
pai(i); // 3
pai(ip); // A number for the place in memory where i is.
pai (*ip); // 3
}
If we pretend we did have an array "memory" for representing the whole of the memory for the computer (program), that last line would essentially be
pai(memory[ip]);
Does that help?
You can't convert between integers and pointers easily though, and that is for several reasons. Most importantly, the size of a pointer and the size of an int may be different. And pointers are treated separately because memory locations aren't "useful" for many other purposes. And hardcoding a pointer address is an extremely bad idea.
-----
The code below may contain other things you don't know, feel free to ask. I didn't test it, so I may have made some error.
Code:
void reverse( char* begin, int len = -1 ) {
if ( -1==len ) len = strlen(begin);
char* end = &begin[len];
while (len>1) {
char c = *begin; // swap the chars pointed to by begin and end
*begin++ = *end; // and increase end -
*end-- = c;
len-=2;
}
}