can anybody tell me how to cut out the middle digits of a number
eg: 255543
=23
Hi...
You should use the function
itoa. After that cutting any digit is very easy.
E.g
1 2 3
|
char str[20];
itoa(str, 356819 , 10);
//str = "356819"
|
Hope this helps (please note the code :))
Last edited on
Last edited on
It's easy even without the strings library:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
int cutMiddleDigits(int input)
{
int OnesDigit = input%10;
int TensDigit;
while (input > 0)
{
TensDigit = input%10;
input /= 10;
}
return 10*TensDigit + OnesDigit;
}
|
Last edited on