fmt_ulong.c

来自「Magic C++!的源代码」· C语言 代码 · 共 28 行

C
28
字号
/* fmt_long.c -- Magic C++ data translate program
   (Mostly) portable public-domain implementation
   -- Copyright(C) 2003 Magicunix Infomation Technology Limited 
   This file is part of magicd.
   magicd is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
	 
   For details, see the Magic C++ World-Wide-Web page, 
   `http://www.magicunix.com',
   or send a mail to the Magic C++ developers <support@magicunix.com>.
 */

#include "fmt.h"

unsigned int fmt_ulong(s,u) register char *s; register unsigned long u;
{
  register unsigned int len; register unsigned long q;
  len = 1; q = u;
  while (q > 9) { ++len; q /= 10; }
  if (s) {
    s += len;
    do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */
  }
  return len;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?