logo

Strpbrk and strspn in C

#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char* argv[]) { char str[] = "Daniel is 25 years old"; char* age = strpbrk(str, "0123456789"); printf("%s\n", age); for (int i = 0; i < strspn(str, "0123456789"); i++) { printf("%c", age[i]); } printf("\n"); return 0; }

Courses with this lesson