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 232 views
1 answer 225 views
1 answer 163 views
163 views asked Aug 6, 2019 by avibootz
1 answer 193 views
193 views asked Aug 5, 2019 by avibootz
1 answer 125 views
1 answer 180 views
...