1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <cstring>
#include <iostream>
int main() {
char str[] = "Hello,World,How,Are,You";
const char* delimiters = ",";
char* token;
// Get the first token
token = std::strtok(str, delimiters);
// Walk through other tokens
while (token != nullptr) {
std::cout << token << std::endl;
token = std::strtok(nullptr, delimiters);
}
return 0;
}
Back to cstring