fork download
  1. //Q100. Print all sub-strings of a string
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int main() {
  6. char str[100];
  7. int i, j, k;
  8. gets(str);
  9. int len = strlen(str);
  10.  
  11. for(i = 0; i < len; i++) {
  12. for(j = i; j < len; j++) {
  13. for(k = i; k <= j; k++)
  14. printf("%c", str[k]);
  15. printf("\n");
  16. }
  17. }
  18. }
  19.  
Success #stdin #stdout 0s 5320KB
stdin
abc
stdout
a
ab
abc
b
bc
c