Hello,

How can I return the string value of octal value.
i.e.
int i;
i = 9 (the octal value is 11),

what should I put at the following line ? :
sprintf(s, "% .... what should I put here ?", i);


Thanks :)

Re: return string value of octal by Eitan

Eitan
Wed May 30 16:24:34 CDT 2007

Also, how can I represent in code the integer octal value
int i;
i = 077 ? - is 077 octal ?

Thanks :)



Re: return string value of octal by Victor

Victor
Wed May 30 16:36:03 CDT 2007

Eitan M wrote:
> Also, how can I represent in code the integer octal value
> int i;
> i = 077 ? - is 077 octal ?

Yes, it is. Any integral literal that begins with 0 is octal.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask



Re: return string value of octal by Victor

Victor
Wed May 30 16:37:06 CDT 2007

Eitan M wrote:
> Hello,
>
> How can I return the string value of octal value.
> i.e.
> int i;
> i = 9 (the octal value is 11),
>
> what should I put at the following line ? :
> sprintf(s, "% .... what should I put here ?", i);

%o, maybe? Have you tried RTFM on 'sprintf' to see all
the formats available?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask



Re: return string value of octal by Cholo

Cholo
Thu May 31 16:04:51 CDT 2007

If you use C++ you can use stringstream:

using namespace std;
streamstring ss;
ss << oct << 9;
string strOctal = ss.str();

--
Cholo Lennon
Bs.As.
ARG


"Eitan M" <no_spam_please@nospam_please.com> wrote in message
news:uDDcH$voHHA.4124@TK2MSFTNGP02.phx.gbl...
> Hello,
>
> How can I return the string value of octal value.
> i.e.
> int i;
> i = 9 (the octal value is 11),
>
> what should I put at the following line ? :
> sprintf(s, "% .... what should I put here ?", i);
>
>
> Thanks :)
>
>



Re: return string value of octal by Tom

Tom
Thu May 31 22:55:59 CDT 2007

Hi Eitan,

I think the %o (oh) method would work for you, but it won't put the '0' on
the front of the number.

http://www.cplusplus.com/reference/clibrary/cstdio/printf.html

You may also find this an interesting read:

http://www.cplusplus.com/doc/hex.html

Tom

"Eitan M" <no_spam_please@nospam_please.com> wrote in message
news:uDDcH$voHHA.4124@TK2MSFTNGP02.phx.gbl...
> Hello,
>
> How can I return the string value of octal value.
> i.e.
> int i;
> i = 9 (the octal value is 11),
>
> what should I put at the following line ? :
> sprintf(s, "% .... what should I put here ?", i);
>
>
> Thanks :)
>