-3

i have

const char* hour = "Wed Mar 23 18:10:57 2016";

I would like to cut "18:10:57" in another new const char*

erip
  • 15,290
  • 10
  • 62
  • 113
SMB Punt
  • 194
  • 1
  • 2
  • 18

1 Answers1

3

I think what you are looking for is the std::strtok() function. There is a reference here.

You will need to copy your original data into a temporary area that does not have the const attribute. std::strtok() will split your string up according to the delimiter you specify, in this case a single blank character.

Each successive call to std::strtok() will advance a pointer to the next token in the string.

Logicrat
  • 4,351
  • 14
  • 22
  • You can't use stroke on a constant string. It modifies the original. – Edward Strange Mar 23 '16 at 17:45
  • 2
    @CrazyEddie That's why my answer included the sentence "You will need to copy your original data into a temporary area that does not have the 'const' attribute." – Logicrat Mar 23 '16 at 18:15