#include <iostream>
#include <cstring>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main()
{
char buf[] = "a\nAB\nabc\nABCD\nabcde\nABCDEF\n";
const char *leksem = "\n";
char *token1 = NULL;
char *next_token1 = NULL;
token1 = strtok_s(buf, leksem, &next_token1);
cout << " token 1 = " << token1 << endl;
vector<char>p(token1, token1 + sizeof(token1) / sizeof(*token1));
cout << " p == ";
for (vector<char>::const_iterator cit = p.cbegin(); cit != p.cend(); ++cit)
{
cout << *cit;
}
cout << endl;
while (token1 != NULL)
{
token1 = strtok_s(NULL, leksem, &next_token1);
cout << " token 1 = " << token1 <<endl;
vector<char>p(token1, token1 + sizeof(token1) / sizeof(*token1));
cout << " p == ";
for (vector<char>::const_iterator cit = p.cbegin(); cit != p.cend(); ++cit)
{
cout << *cit;
}
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHN0cmluZy5oPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSAKewoJY2hhciBidWZbXSA9ICJhXG5BQlxuYWJjXG5BQkNEXG5hYmNkZVxuQUJDREVGXG4iOwoKCWNvbnN0IGNoYXIgKmxla3NlbSA9ICJcbiI7ICAgICAgICAgICAgIAoJY2hhciAqdG9rZW4xID0gTlVMTDsKCWNoYXIgKm5leHRfdG9rZW4xID0gTlVMTDsKCgl0b2tlbjEgPSBzdHJ0b2tfcyhidWYsIGxla3NlbSwgJm5leHRfdG9rZW4xKTsKCWNvdXQgPDwgIiB0b2tlbiAxID0gIiA8PCB0b2tlbjEgPDwgZW5kbDsKCXZlY3RvcjxjaGFyPnAodG9rZW4xLCB0b2tlbjEgKyBzaXplb2YodG9rZW4xKSAvIHNpemVvZigqdG9rZW4xKSk7Cgljb3V0IDw8ICIgcCA9PSAiOwoJZm9yICh2ZWN0b3I8Y2hhcj46OmNvbnN0X2l0ZXJhdG9yIGNpdCA9IHAuY2JlZ2luKCk7IGNpdCAhPSBwLmNlbmQoKTsgKytjaXQpCgkJewoJCQljb3V0IDw8ICpjaXQ7CgkJfQoJY291dCA8PCBlbmRsOwoJd2hpbGUgKHRva2VuMSAhPSBOVUxMKQoJewoJCXRva2VuMSA9IHN0cnRva19zKE5VTEwsIGxla3NlbSwgJm5leHRfdG9rZW4xKTsKCQljb3V0IDw8ICIgdG9rZW4gMSA9ICIgPDwgdG9rZW4xIDw8ZW5kbDsKCQl2ZWN0b3I8Y2hhcj5wKHRva2VuMSwgdG9rZW4xICsgc2l6ZW9mKHRva2VuMSkgLyBzaXplb2YoKnRva2VuMSkpOwoJCWNvdXQgPDwgIiBwID09ICI7CgkJZm9yICh2ZWN0b3I8Y2hhcj46OmNvbnN0X2l0ZXJhdG9yIGNpdCA9IHAuY2JlZ2luKCk7IGNpdCAhPSBwLmNlbmQoKTsgKytjaXQpCgkJCXsKCQkJCWNvdXQgPDwgKmNpdDsKCQkJfQoJCWNvdXQgPDwgZW5kbDsKCX0KcmV0dXJuIDA7Cn0=
prog.cpp: In function 'int main()':
prog.cpp:16:45: error: 'strtok_s' was not declared in this scope
token1 = strtok_s(buf, leksem, &next_token1);
^