Get a substring of a char* [duplicate]
Assuming you know the position and the length of the substring:
char *buff = "this is a test string";printf("%.*s", 4, buff + 10);
You could achieve the same thing by copying the substring to another memory destination, but it's not reasonable since you already have it in memory.
This is a good example of avoiding unnecessary copying by using pointers.