i have an array which has all the alphabet characters in it and an input array and an output array. I have to use strspn and strncat in the function.
Input = "fggh%^^hf"
output - empty
now i have to copy all alpha characters from input into ouput, but it doesnt seem to wokr, since strspn only uses the first occurences of alphabet characters in input so it would only take the fggh and skip the rest. My problem is how to get the rest of the letters copied into output
so output should be fgghhf
here is what i have tried, i hope u can help me out
Code:
int s = 0;
size = strspn(input, alphabet);
strncat(out, input, s);
for ( i = 0; In[i] != '\0'; i++ )
{
for ( j = 0; Alpha[j] != '\0'; j++ )
{
if ( Alpha[j] == In[i] )
{
In[i] = Out[x];
x++;
break;
}
}
}
can someone help?