-3
I need to print substrings for a string, for example: OPEN, substrings are OPEN, OPEN, ABR, AB, A. How do I do this? 'Cause all I’m doing is printing the whole 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;
}
What is the doubt?
– Marcelo Shiniti Uchimura
@Marcelouchimura how do I print these subtrings, because I can only print the entire string
– Vinicius Souza