Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I wish to convert form a char array 1

Status
Not open for further replies.

sweep123

Technical User
Joined
May 1, 2003
Messages
185
Location
GB
I wish to convert form a char array to an octal number
i.e.
char addr_nr[ADDR_NR_LENGTH+1];

addr_nr will hold '11337'

and I wish to convert to a value -

int octal_nr = charToOctal(addr_nr);

Is this possible
 
Wow, octals. I thought noone ever used them...

Prepend it with a "0" and use the strtol(...) function.

As MSDN states:
"If the first character is 0 and the second character is not 'x' or 'X', the string is interpreted as an octal integer"

/Per
Nerdy signatures are as lame as the inconsistent stardates of STTNG.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top