You may try like this:
char *tmp= message + 20;
문제
I have a char *message;
which contains some content.
I wish to read this message from a specific index (for example 20) and until end of the char*
. Is there any clever way to do this? I have been looking at memcpy()
and the possibility to copy a "sub-string" from message
into a new char *tmp;
, but I can't seem to figure out how to start at that specific index (for example 20) and copy until end of message
-- rather than starting at the beginning of message
.
Any help appreciated. Cheers!
해결책
You may try like this:
char *tmp= message + 20;
다른 팁
this is an example to test your need :
main()
{
char *buff = "hello_word_test";
char *tmp;
printf("%s \n",buff);
printf("%s \n",buff+5);
}
result :
hello_word_test
_word_test
5 is an index , you can change it as well as you need