1. 程式人生 > >linux下字串和整型互轉

linux下字串和整型互轉

int tm=1234567890;

char *p = malloc(10*sizeof(char));

        sprintf(p,"%d",tm);      tm轉字串
        printf("--------%s\n",p);
        int t2;
        t2 = atoi(p);             字串轉整型
        printf("=======%d\n",t2);