fork(14) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(void) {
  6. char str[] = "(20*(5+(7*2)))+((2+8)*(3+6*9))";
  7. char *copy = strdup(str);
  8. char *delim = "*+()";
  9. char *res = strtok( str, delim );
  10. while (res) {
  11. int from = res-str+strlen(res);
  12. res = strtok( NULL, delim );
  13. int to = res != NULL ? res-str : strlen(copy);
  14. printf("%.*s\n", to-from, copy+from);
  15. }
  16. free(copy);
  17. return 0;
  18. }
Success #stdin #stdout 0s 2244KB
stdin
Standard input is empty
stdout
*(
+(
*
)))+((
+
)*(
+
*
))