How to extract number and substring from a string in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    char str[64] = "8392871 c programming";
    char *p;

    long n = strtol(str, &p, 10);

    printf("%ld\n", n);
    printf("%s", p);

    return(0);
}





/*
run:

8392871
 c programming

*/

 



answered May 3, 2021 by avibootz

Related questions

...