SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
C program to find all substrings of a string
C program to find all substrings of a string
Output:
Enter the string: code
All substrings of string 'code' are:
code ode de cod co c o d e
Implementation:
#include
#include
#include
int main(void) { char *s,temp; int i,len; s=(char*)malloc(sizeof(char)); printf("Enter the string:\n"); scanf("%s",s); printf("All substrings of string '%s' are:\n"); i=0; len=strlen(s)-1; for(i=0;i
1) { temp=*(s+len); *(s+len)='\0'; printf("%s ",s); *(s+len)=temp; len--; } i=0; while(*(s+i)) { printf("%c ",*(s+i)); i++; } return 0; }
PREVIOUS
NEXT
HOME