I need to print the substrings of a string, for example: OPEN, the substrings are OPEN, ABRI, ABR, AB, A. How do I do this? Because I can only print the entire string.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void subtring(char *ch, int size, int aux) {
if (size > 0) {
subtring(ch, size - 1);
printf("%c", ch[size - 1]);
}
}
int main(int argc, char const *argv[]) {
char ch[100];
printf("Digite uma palavra -> ");
gets(ch);
int size = strlen(ch);
subtring(ch, size);
return 0;
}