You can use the strstr () function, this function checks for a substring in a string, then just count the number of characters in the substring compared to the string, or the strncmp ()
If it is to check only from the beginning, Ex:
112
1125468
In this case, you can loop through the character, if it is different, give break
and conclude that it is not a Subsequence
It will also be necessary to allocate memory of 10^10
and 10^32
in the 2 strings, as requested by the exercise.
Code :
#include <stdio.h>
#include <string.h>
int main(void)
{
char N1[100], N2[100];
int count=0, x=0;
scanf(" %s",N1);
scanf(" %s", N2);
do
{
if(!strncmp(N2+x, N1, strlen(N1)))
{
count++;
printf("N1 e´ uma substring de N2\n");
printf("Qtd.Subsequencias %d\n", count);
x+=strlen(N1);
}
else
x+=1;
} while(x<strlen(N2));
}
I think this is what you want to do, of course we have to take the prints in the loop, but that's just an example
STDIN
12
123123123123
STDOUT
N1 e´ uma substring de N2
Qtd.Subsequencias 4
As we can see, in the last iteration Qtd.Subsequencias equals 4.
In this case the quickest way would be to use the strncmp ()