Monday, September 21, 2009

OOP344 Challenge1

assume the integer>0

GetInt(char *strint, int val){

int i, temp = val, len = 1;

//count the length of val
while((val /= 10)>0)
len++;

//write char in array
strint[len] = '\0';
for(i = len-1; i >= 0; i--){
strint[i] = temp % 10 + 48;
temp /= 10;
}
}

No comments:

Post a Comment