fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include<ctype.h>
  4.  
  5. int main() {
  6. char str[512], word[256];
  7. int i = 0, j = 0;
  8.  
  9. printf("Enter your input string:");
  10. gets(str);
  11.  
  12. while (str[i] != '\0') {
  13. //how to separate strings (words) when changed from
  14.  
  15. // Is the next character the end of the string?
  16. if(str[i+1] != '\0'){ // <<<
  17. //uppercase, lowercase or digit?
  18. if (
  19. isdigit(str[i]) && (isupper(str[i+1]) || islower(str[i+1])) // <<<
  20. || isupper(str[i]) && (isdigit(str[i+1]) || islower(str[i+1])) // <<<
  21. || islower(str[i]) && (isupper(str[i+1]) || isdigit(str[i+1])) // <<<
  22. ){
  23. word[j] = str[i]; // <<<
  24. word[j+1] = '\0'; // <<<
  25. printf("%s\n", word);
  26. j = 0;
  27. } else {
  28. word[j++] = str[i];
  29. }
  30. }
  31. else {
  32. // End of the string
  33. word[j] = str[i]; // <<<
  34. word[j+1] = '\0'; // <<<
  35. printf("%s\n", word);
  36. }
  37. i++;
  38. }
  39. return 0;
  40. }
Success #stdin #stdout 0s 2116KB
stdin
thisIS1inputSTRING
stdout
Enter your input string:this
IS
1
input
STRING