Advertisement
LosPollos

Home task 2-5 Error

Feb 27th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. /*
  2. 3. Задать строку, скопировать в неё
  3. «James, while John had had "had", had had "had had"; "had had" had had a better effect on the teacher».
  4. (Примечание. Чтобы вставить кавычку посреди строки, её нужно экранировать: \".)
  5. Продемонстрировать работу функции strtok() с разными символами в качестве разделителя
  6. (пробелом, запятой, пробелом и запятой, точкой с запятой).
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <string.h>
  11.  
  12. #define size 256u
  13.  
  14. int main()
  15. {
  16.     char arr[size] = { 0 };
  17.     char* arr2 = "James, while John had had \"had\", had had \"had had\"; \"had had\" had had a better effect on the teacher";
  18.     strcpy_s(arr, size, arr2);
  19.  
  20.     printf("%s\n", arr);
  21.  
  22.     char* token = strtok_s(arr, size, " "); // Error here.
  23.     puts(token);
  24.  
  25.  
  26.     printf("%s\n", arr);
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement