it contain 0 , so that when we get last digit to check whether it is 8 OR 9 by using % (mode) it give other value (as we do it divide method) , i also try it to convert integer to string and than i m also not able to get last digit to check its octal value .... so please send me full programm in which octal value is check........
Octal is just another kind of representation of an integer as a string. I guess you're talking about that string. To check whether the string contains only octal number the check + conversion would look like this
1 2 3 4 5 6 7 8 9 10 11 12 13
int val = 0;
int factor = 1;
for(int i = 0; i < str_size; ++i)
{
constint cur_digit = str_size - i - 1;
if((str[cur_digit] >= '0') && (str[cur_digit] <= '8'))
{
val += (str[cur_digit] - '0') * factor;
factor *= 8;
}
elsebreak; // not octal
}