Printing leading 0's in C?

前端 未结 10 1391
[愿得一人]
[愿得一人] 2020-11-22 17:26

I\'m trying to find a good way to print leading 0\'s, such as 01001 for a zipcode. While the number would be stored as 1001, what is a good way to do it?

I thought

10条回答
  •  误落风尘
    2020-11-22 17:54

    The correct solution is to store the zip code in the database as a STRING. Despite the fact that it may look like a number, it isn't. It's a code, where each part has meaning.

    A number is a thing you do arithmetic on. A zip code is not that.

提交回复
热议问题