It would be stored on the heap in case you declare it in this way: char * s = newchar[]="chris";
However it needn't to be stored on the heap to make the program working. Declare the other two parameters of your reverse function as pointers as well and it should work.
2) char *s= new char[]="chris";
This one gave the same error "Access Violation writing location 0x00e47810"
@Danielsson: Tried converting the other 2 parameters to pointers, but was not able to convert the first call to the function where the integer position values are passed, donno how to pass the address for int positions.....
char* s is a variable that lives on the stack, but "chris" is a constant string that is not. I many modern architectures, it's stored in a data segment, and in your case, is marked constant (luckily).
If you want a string declared on the stack, do char s[] = "chris";
This is something I'm a bit shaky about: stack vs heap. In principle I know what they are, but I don't understand the idea/purporse behind the concepts. When something is in the stack memory is allocated when the function is entered and freed on fuction return. To place something in the heap, on the other hand, the memory must be manually reserved and freed. Are these premises correct? What is the advantage of using the heap?
The problem is that the string given here char *s="chris"; is stored in
the program data segment - and is READ only - and therefore cannot be reversed
as reversing the string means writing to it - hence the error.