I am trying to make a substring from a string using a function that returns a pointer. When I try to assign the value pointed by one pointer to another pointer the program just stops executing. It compiles fine however with no errors or anything.
Anyway I am a newbie and was wondering if anybody can see a problem in the code
This: *ptr=*str;
doesn't work, because you didn't allocate memory for pointer ptr. So you should write for example: char *ptr=newchar[20];
Also, you don't have to write: *(ptr++);
Write: ptr++;
instead.