converting char array into one int

Posted by user1762517 on Stack Overflow See other posts from Stack Overflow or by user1762517
Published on 2012-10-21T03:52:48Z Indexed on 2012/10/21 5:02 UTC
Read the original article Hit count: 197

Filed under:
|
|

I can't use atoi, need to do it digit by digit.. How do I save it in a int.. given a char* temp put it all in one int..

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main () {

    char* temp = "798654564654564654";
    int i = 0;

    for (i = 0; i < strlen(temp); i++) {

        printf("%d", temp[i] - 48);

    }

    printf("\n");

}

© Stack Overflow or respective owner

Related posts about c

    Related posts about gcc