fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4.  
  5. void tokenizeLine(char *array[13]; char* line)
  6. {
  7. char buf[] = "hehe,1,2,2,2,2,2,2,2,2,2,2,4\0\n";
  8. // strcpy(buf,line);
  9. int i = 0;
  10. char *p = strtok (buf, ",");
  11. printf("%s",p);
  12.  
  13. while (p != NULL)
  14. {
  15. array[i++] = p;
  16. p = strtok (NULL, ",");
  17. printf("%s",p);
  18. }
  19. }
  20.  
  21. int main ()
  22. {
  23. char *array[13];
  24. tokenizeLine(array, "hehe,1,2,2,2,2,2,2,2,2,2,2,4\n");
  25.  
  26. for (int i = 0; i < 13; i++)
  27. printf("%s\n", array[i]);
  28.  
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 9424KB
stdin
Standard input is empty
compilation info
prog.c:5:25: error: parameter ‘array’ has just a forward declaration
 void tokenizeLine(char *array[13]; char* line)
                         ^~~~~
prog.c: In function ‘tokenizeLine’:
prog.c:15:9: error: ‘array’ undeclared (first use in this function)
         array[i++] = p;
         ^~~~~
prog.c:15:9: note: each undeclared identifier is reported only once for each function it appears in
prog.c: In function ‘main’:
prog.c:24:18: warning: passing argument 1 of ‘tokenizeLine’ from incompatible pointer type [-Wincompatible-pointer-types]
     tokenizeLine(array, "hehe,1,2,2,2,2,2,2,2,2,2,2,4\n");
                  ^~~~~
prog.c:5:6: note: expected ‘char *’ but argument is of type ‘char **’
 void tokenizeLine(char *array[13]; char* line)
      ^~~~~~~~~~~~
prog.c:24:5: error: too many arguments to function ‘tokenizeLine’
     tokenizeLine(array, "hehe,1,2,2,2,2,2,2,2,2,2,2,4\n");
     ^~~~~~~~~~~~
prog.c:5:6: note: declared here
 void tokenizeLine(char *array[13]; char* line)
      ^~~~~~~~~~~~
stdout
Standard output is empty