Strcspn in c
Strcspn function in c programming use to find the first character in the given string that is equal to the character of the other string.
Null characters are not included in this string search.
strcspn function also know the end of the string with the null character (/0)
This function return the index of the first character in the string.
Example
#include<stdio.h> #include <string.h> #define SIZE 40 int main(void) { char string[SIZE] = "source string"; char * substring = "alax"; printf( "The first %i characters in the string \"%s\" " "are not in the string \"%s\" \n", strcspn(string, substring), string, substring); }
OUTPUT
the first 10 character from string1("source string") are not in the given sting2 ("alax")
0 comments:
Post a Comment