Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
atoi()ファイルからの読み取り中に使用すると、一部の郵便番号で最初の 0 が削除されます。次に例を示します。
atoi()
int x = atoi("06461");
節約しているようx = 6461です。関数の重要でない 0 の部分を削除していatoiますか?
x = 6461
atoi
ゼロにはなりません。番号を格納します。また、数値 (10 進数) として 06461 と 6461 はまったく同じ値です。数字をどのように表示するかはあなた次第です—先行ゼロを付けて ( printf("%05d",zip)) 付けるか付けずに (%dの場合)。printf
printf("%05d",zip)
%d
printf
PS 注: c の人々は先頭の 0 に混乱する可能性があり、数字を 8 進数と見なす傾向があります。PPSそして、私はあなたの質問に対するヨアヒムのコメントを完全に支持します.