-->

WAP to find initial segment of string that consists entirely of characters from second string. using strspn() function.

in turboc++
--------------------------------------------------------------------------------------------------------------
//WAP to  know location of difference of string (segment)in another string using  strspn() function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char st[100],st1[100];// declaration
    printf("enter  string\n");
    gets(st);
    printf("enter second string\n");
     gets(st1);//inputs
    strspn(st,st1);
    printf("location of difference=%d\n",strspn(st,st1));//prints the location from where segment is //different
   getch();
    return 0;
}

-------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------------
//WAP to  know location of difference of string (segment)in another string using  strspn() function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1[100];// declaration
    printf("enter  string\n");
    gets(st);
    printf("enter second string\n");
     gets(st1);//inputs
    strspn(st,st1);
    printf("location of difference=%d\n",strspn(st,st1));//prints the location from where segment is different
    return 0;
}

No comments:

Post a Comment