By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,483 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

how to convert a base 8 number into decimal number... help me pls thks

P: 8
pls help to solve this problem : using C programming to convert a base 8 number into a decimal number... thks
Nov 16 '06 #1
Share this Question
Share on Google+
4 Replies


Banfa
Expert Mod 5K+
P: 8,916
Do you mean a string containing a base 8 number?

C/C++ only operates in 1 base, base 2 (binary), all other bases are just input/output notations because humans find binary a little hard to read.
Nov 16 '06 #2

P: 8
c2h
Hi, Banfa... thanks for your reply. I also not very sure. But the question is : using a appropriate programming language, write a program that convert a whole number input by the user from base 8 to base 10. The program should flag as an error any input that contain 8 or 9.

i very appreciate ur reply. can u suggest for me what else programming language is appropriate to this question.. ? thanks
Nov 16 '06 #3

Banfa
Expert Mod 5K+
P: 8,916
A-ha the real specification always helps.

So you need to convert an ASCII string of digits to a binary value assuming that the string of digits is given in base 8.

The is a function in the standard library that will do this without too much hassle

long strtol ( const char * string, char** endptr, int radix );

Look it up, it is declared in stdlib.h
Nov 16 '06 #4

P: 8
c2h
haha.... thankyou.... actually i not very understand, but i will try to find it out...
thanks you a lot
Nov 16 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.