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