#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);
vector<char>p(token1, token1 + sizeof(token1) / sizeof(*token1));
cout << " token 1 = " << token1 <<endl;
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);
vector<char>p(token1, token1 + sizeof(token1) / sizeof(*token1));
cout << " token 1 = " << token1 <<endl;
cout << " p == ";
for (vector<char>::const_iterator cit = p.cbegin(); cit != p.cend(); ++cit)
{
cout << *cit;
}
cout << endl;
return 0;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHN0cmluZy5oPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSAKewpjaGFyIGJ1ZltdID0gImFcbkFCXG5hYmNcbkFCQ0RcbmFiY2RlXG5BQkNERUZcbiI7CmNvbnN0IGNoYXIgKmxla3NlbSA9ICJcbiI7ICAgICAgICAgICAgIApjaGFyICp0b2tlbjEgPSBOVUxMOwpjaGFyICpuZXh0X3Rva2VuMSA9IE5VTEw7CnRva2VuMSA9IHN0cnRva19zKGJ1ZiwgbGVrc2VtLCAmbmV4dF90b2tlbjEpOwp2ZWN0b3I8Y2hhcj5wKHRva2VuMSwgdG9rZW4xICsgc2l6ZW9mKHRva2VuMSkgLyBzaXplb2YoKnRva2VuMSkpOwpjb3V0IDw8ICIgdG9rZW4gMSA9ICIgPDwgdG9rZW4xIDw8ZW5kbDsKY291dCA8PCAiIHAgPT0gIjsKZm9yICh2ZWN0b3I8Y2hhcj46OmNvbnN0X2l0ZXJhdG9yIGNpdCA9IHAuY2JlZ2luKCk7IGNpdCAhPSBwLmNlbmQoKTsgKytjaXQpCnsKY291dCA8PCAqY2l0Owp9CmNvdXQgPDwgZW5kbDsKd2hpbGUgKHRva2VuMSAhPSBOVUxMKQp7CnRva2VuMSA9IHN0cnRva19zKE5VTEwsIGxla3NlbSwgJm5leHRfdG9rZW4xKTsKdmVjdG9yPGNoYXI+cCh0b2tlbjEsIHRva2VuMSArIHNpemVvZih0b2tlbjEpIC8gc2l6ZW9mKCp0b2tlbjEpKTsKY291dCA8PCAiIHRva2VuIDEgPSAiIDw8IHRva2VuMSA8PGVuZGw7CmNvdXQgPDwgIiBwID09ICI7CmZvciAodmVjdG9yPGNoYXI+Ojpjb25zdF9pdGVyYXRvciBjaXQgPSBwLmNiZWdpbigpOyBjaXQgIT0gcC5jZW5kKCk7ICsrY2l0KQp7CmNvdXQgPDwgKmNpdDsKfQpjb3V0IDw8IGVuZGw7CglyZXR1cm4gMDsKfQp9
prog.cpp: In function 'int main()':
prog.cpp:14:44: error: 'strtok_s' was not declared in this scope
token1 = strtok_s(buf, leksem, &next_token1);
^