I have a string having 12 characters in it, and want to convert that in int or we can say digit , but not able to do it. i have written a code which converts string up to 11 digits but after that it starts giving garbage value. my code is like
#include<stdio.h>
double myAtoi(char *str);
void main()
{
    double n;
    double m;
    char* a="12345678912";
    char* b="34";
    n=myAtoi(a);
    //m=atoi(b);
    printf("\nconversion is : %d",(n));
}
double myAtoi(char *str)
{   
    printf("\nstr : %s",str);
    long res = 0; // Initialize result
    long i ;
    // Iterate through all characters of input string and update result
    for (i = 0; str[i] != '\0'; ++i)
    {
        res = res*10 + str[i] - '0';
        printf("\n res : %d",res);
        //x=res;
    }
    return res;
}
 
     
     
     
    