Please help on a REVERSED Sub String

Guys, stuck in the middle...
I have a char string, debugCommand[20] coming from Serial as bmsping.
I need to strip out only the ping and store it to bmsCommand[10].

I will always get different char Strings where the first 3 char will always be bms and rest part will be something else. like bmsC01 bmsD01 bmsping etc. It is a single string, no deliminator involved. Now, I tried using strncpy()

char debugCommand[20] = "bmsping";
char bmsCommand[10];

strcpy(bmsCommand, debugCommand, 3);

and that's a failure of my need as this gives bms. not ping. Using strstr() is also failed as all I want is to eliminate the bms and make a substring of whatever later.

Please help!!

strcpy(bmsCommand, &debugCommand[3]);


strcpy(bmsCommand, &debugCommand[3]);

WOW!! That was a magic!! WOW!!!!!!
Can you please explain how the magic worked??

"&debugCommand[3]" is the memory address of the character array element containing "p", the first character of the substring "ping".

aaaa... so that means next time if i need to skip a part from start, I can use this way (in case of known). This starts from address 3 (holding p) to copy all the way till NULL. right??

Thanks man, thanks a lot!!!

There are several handy little string processing routines like strcpy(), including searches.

See them here <cstring> (string.h) - C++ Reference