fork(2) 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. const char *leksem = "\n";
  12. char *token1 = NULL;
  13. char *next_token1 = NULL;
  14. token1 = strtok_s(buf, leksem, &next_token1);
  15. vector<char>p(token1, token1 + sizeof(token1) / sizeof(*token1));
  16. cout << " token 1 = " << token1 <<endl;
  17. cout << " p == ";
  18. for (vector<char>::const_iterator cit = p.cbegin(); cit != p.cend(); ++cit)
  19. {
  20. cout << *cit;
  21. }
  22. cout << endl;
  23. while (token1 != NULL)
  24. {
  25. token1 = strtok_s(NULL, leksem, &next_token1);
  26. vector<char>p(token1, token1 + sizeof(token1) / sizeof(*token1));
  27. cout << " token 1 = " << token1 <<endl;
  28. cout << " p == ";
  29. for (vector<char>::const_iterator cit = p.cbegin(); cit != p.cend(); ++cit)
  30. {
  31. cout << *cit;
  32. }
  33. cout << endl;
  34. return 0;
  35. }
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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);
                                            ^
stdout
Standard output is empty