How to convert the initial part of a string to long int in C

1 Answer

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

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

    long n = strtol(str, NULL, 10);

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

    return(0);
}





/*
run:

31592871

*/

 



answered May 3, 2021 by avibootz

Related questions

1 answer 177 views
1 answer 188 views
1 answer 132 views
132 views asked Aug 6, 2019 by avibootz
1 answer 155 views
155 views asked Aug 5, 2019 by avibootz
1 answer 90 views
1 answer 135 views
...