Demo Spanning Strings, Strspn() and Strcspn()

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> #include <string.h> #include <stdio.h> /* size_t strspn ( char *stting, char *set_to_skip_over) ; size_t strcspn( char *string, char *set_to_find_in) Q are there chars in char set *set_to_find, return #chars skipped until char found Q are there chars in char set *set_to_skip_over, return #chars skipped until char found */ int main(void) { char sentence[] = "Hello. I am John!" ; char nonsense[] = "~*%#" ; char letters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz" ; int numskipped; numskipped = strcspn (sentence, letters) ; printf ("%d chars skipped over until a letter was found.\n", numskipped) ; numskipped = strspn (sentence, letters) ; printf ("%d chars skipped over until a non-letter was found.\n", numskipped) ; numskipped = strcspn (sentence, nonsense) ; printf ("%d chars skipped over until a nonsense character was found.\n", numskipped) ; return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines