hello, i have a problem in converting an octal number to its binary form, using ltoa...
well i have a small program in C , that does this job , just fine ,
but i have to make it in C++, meaning i will not need any scanf() , so here is the problem , i dont know how i can feed the ltoa ! if i convert a decimal number to octal (suppose i is the decimal number , i convert it to octal and save it again in 'i' , when i use it in ltoa, it wont work!!)
(see the following example, it just works fine, but if i omit scanf("%o",&i) , and i feed the ltoa (the number 77 which is octal )it wont work! if i use a decimal number and convert it to octal and then feed the ltoa , again it wont work!! where is the problem ? is there any counterpart for C++? or a way to manipulate octals ? i mean we have "%0" in C , do we have such thing is C++ that returns an octal number?
/* ltoa example */
int main ()
char buffer [sizeof(long)*8+1];
char * str;
printf ("Enter a number: ");
printf ("decimal: %s\n",buffer);
printf ("hexadecimal: %s\n",buffer);
printf ("binary: %s\n",buffer);