fork download
  1. #include<string.h>
  2. #include<stdlib.h>
  3.  
  4. char **allsubstring(char *);
  5.  
  6. // The function will return array of the substring
  7.  
  8. char** allsubstring(char *input)
  9. {
  10.  
  11. int index1,index2,index3,noofsubstring,index4,index5;
  12. char ** strarray;
  13. char *buffer;
  14. if(input == NULL) { printf("there is no string\n"); return NULL;}
  15.  
  16. noofsubstring=(strlen(input)*(strlen(input)+1))/2;
  17.  
  18. buffer = (char *)malloc(sizeof(char)*strlen(input));
  19. strarray = (char **) malloc(sizeof(char *)*noofsubstring);
  20.  
  21. index5=-1;
  22. for(index1=strlen(input)-1;index1>=0;--index1)
  23. {
  24. for(index2=0;index2<=index1;++index2)
  25. {
  26. index4=0;
  27. for(index3=index2;index3<=index1;++index3)
  28. {
  29. sprintf(buffer+index4,"%c",input[index3]);
  30. ++index4;
  31. }
  32. sprintf(buffer+index4,"%c",'\0');//printf("%s\n",buffer);
  33. strarray[++index5] = (char *)malloc(sizeof(char)*strlen(buffer));
  34. strcpy(strarray[index5],buffer);
  35. }
  36. }
  37. free(buffer);
  38. return strarray;
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:14:21: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)'
if(input == NULL) { printf("there is no string\n"); return NULL;}
                    ^
prog.c:14:21: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
prog.c:29:4: warning: implicitly declaring library function 'sprintf' with type 'int (char *, const char *, ...)'
   sprintf(buffer+index4,"%c",input[index3]);
   ^
prog.c:29:4: note: include the header <stdio.h> or explicitly provide a declaration for 'sprintf'
2 warnings generated.
/usr/bin/../lib/gcc/i586-linux-gnu/4.9/../../../i386-linux-gnu/crt1.o: In function `_start':
/build/glibc-5CYv_T/glibc-2.19/csu/../sysdeps/i386/start.S:111: undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
stdout
Standard output is empty