English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Libreria standard C - <string.h>
Funzione della libreria C size_t strspn(const char *str1, const char *str2) Cerca stringa str1 primo carattere non presente nella stringa str2 indice del carattere che compare nella stringa
Di seguito è riportata la dichiarazione della funzione strspn().
size_t strspn(const char *str1, const char *str2)
La funzione restituisce l'indice del primo carattere di str1 che non compare nella stringa str2.
Ese esempio dimostra l'uso della funzione strspn().
#include <stdio.h> #include <string.h> int main () { int len; const char str1[] = "ABCDEFG019874"; const char str2[] = "ABCD"; len = strspn(str1, str2); printf("Lunghezza di match iniziale %d\n", len ); return(0); }
Compiliamo ed eseguiamo il programma sopra, questo produrrà i seguenti risultati:
Lunghezza di match iniziale 4