fork download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <string.h>
  4. #include <string>
  5. #include <vector>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. char buf[] = "a\nAB\nabc\nABCD\nabcde\nABCDEF\n";
  11.  
  12. const char *leksem = "\n";
  13. char *token1 = NULL;
  14. char *next_token1 = NULL;
  15.  
  16. token1 = strtok_s(buf, leksem, &next_token1);
  17. cout << " token 1 = " << token1 << endl;
  18. vector<char>p(token1, token1 + sizeof(token1) / sizeof(*token1));
  19. cout << " p == ";
  20. for (vector<char>::const_iterator cit = p.cbegin(); cit != p.cend(); ++cit)
  21. {
  22. cout << *cit;
  23. }
  24. cout << endl;
  25. while (token1 != NULL)
  26. {
  27. token1 = strtok_s(NULL, leksem, &next_token1);
  28. cout << " token 1 = " << token1 <<endl;
  29. vector<char>p(token1, token1 + sizeof(token1) / sizeof(*token1));
  30. cout << " p == ";
  31. for (vector<char>::const_iterator cit = p.cbegin(); cit != p.cend(); ++cit)
  32. {
  33. cout << *cit;
  34. }
  35. cout << endl;
  36. }
  37. return 0;
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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);
                                             ^
stdout
Standard output is empty