a simple question:
this function worked perfectly on my 32 Bit Linux then I got a 64 Bit Linux and now it is no longer working. I've narrowed it down to this function in converting the data from Char to Int. it no longer does this. this is where I am stuck at right now. all this functions is doing is taking a format like this 100x100 then chopping out the x and keeping the two numbers on both sides then changing them into Int's.
Using atoi is now returning junk now that I am running it on this 64bit Linux. what function call do I have to use that will make it work again only on both 32 and 64 bit Linux programs now?
int findX(char *whereisX, int *rW, int *rH)
{
printf("entering findx dia is %s\n\n", whereisX);
char *tok1, *tok2, *saveptr;
char x = (int) malloc(sizeof(whereisX));
char str1[x];
int bW, bH;
strcpy(str1, whereisX);
tok1 = strtok_r(whereisX, "x", &saveptr);
tok2 = strtok_r(NULL, "x", &saveptr);
if ( tok2 == NULL)
{ printf("found return 1\n");
return 1;
}
else
{ printf("returning 0\n");
tok1 = strtok_r(str1, "x", &saveptr);
tok2 = strtok_r(NULL, "x", &saveptr);
printf("tok1 is .. %s and tok2 is %s\n", tok1 , tok2);
// here is where I am converting it from Char to Int
// using atoi now gives me back junk
// bW = atoi(tok1);
// bH = atoi(tok2);
bW = atoll(tok1);
bH = atoll(tok2);
printf("bW is %c and bH is %c\n", bW, bH);
// printf("string -- bW is %s and bH is %s\n", bW,bH);
/* assigning the results to the output */
*rW = bW;
*rH = bH;
printf("rW is %s rH is %s\n", rW , rH);
return 0;
}
} //end findX
output is
tok1 is .. 200 and tok2 is 100
// after converting from char to int using atoi
bW is � and bH is d
rW is � rH is d