Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. char ** get_tokens() {
  5. //printf("get tokens...\n");
  6. char *s1 = "hello";
  7. char *s2 = "world!";
  8. char *s3 = "...char**";
  9. char *s4 = " is hard!";
  10.  
  11. char **ch = (char **)malloc(4 * sizeof(char *));
  12. *ch = s1;
  13. *(ch+1) = s2;
  14. *(ch+2) = s3;
  15. *(ch+3) = s4;
  16.  
  17. return ch;
  18. }
  19.  
  20. int main() {
  21. char ** tokens = get_tokens();
  22. while(*tokens != NULL) {
  23. char *p = *tokens;
  24. printf("HERE: %s\n", p);
  25. tokens++;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement