字符串到八进制 [英] String to Octal

查看:143
本文介绍了字符串到八进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读一个八进制数字参数并将其存储为

八进制数。例如,用户将输入:./a.out 777并且它

将存储八进制数777.但它atoi做这个作为一个整数,

和sscanf给出我0.

I want to read in an Octal number argument and have it stored as an
octal number. For instance the user will type: ./a.out 777 and it
will store the octal number 777. But it atoi does this as an interger,
and sscanf gives me 0.

推荐答案

文章< 11 ***************** ***@g47g2000cwa.googlegroups.c om>,

< fu ****** @ kettering.edu>写道:
In article <11********************@g47g2000cwa.googlegroups.c om>,
<fu******@kettering.edu> wrote:
我想读一个八进制数字参数并将其存储为八进制数字。例如,用户将输入:./a.out 777并且它将存储八进制数777.但它atoi将此作为一个整数,
和sscanf给我0。
I want to read in an Octal number argument and have it stored as an
octal number. For instance the user will type: ./a.out 777 and it
will store the octal number 777. But it atoi does this as an interger,
and sscanf gives me 0.




strtoul()指定基数为8.

-

如果你撒谎到编译器,它将报复。 - Henry Spencer



strtoul() specifying a base of 8.
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer


谢谢!

Thanks!


fu ****** @ kettering.edu 写道:
fu******@kettering.edu writes:
我想读一个八进制数字参数并且有它存储为八进制数。例如,用户将输入:./a.out 777并且它将存储八进制数777.但它atoi将此作为一个整数,
和sscanf给我0。
I want to read in an Octal number argument and have it stored as an
octal number. For instance the user will type: ./a.out 777 and it
will store the octal number 777. But it atoi does this as an interger,
and sscanf gives me 0.




使用strtol(),指定基数8.

-

"我现在一直在旅行车上十多年了。在那段时间里没有一个转到

。我不再需要它们了。我现在甚至没有使用

休息或继续,当然除了在社交场合。而且我不会被带走。 - 理查德希思菲尔德



Use strtol(), specifying base 8.
--
"I''ve been on the wagon now for more than a decade. Not a single goto
in all that time. I just don''t need them any more. I don''t even use
break or continue now, except on social occasions of course. And I
don''t get carried away." --Richard Heathfield


这篇关于字符串到八进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆