设为首页 加入收藏

TOP

C语言学习趣事_MSCRT_IO_SourceFile (八)
2014-11-24 00:40:18 来源: 作者: 【 】 浏览:261
Tags:语言学习 趣事 _MSCRT_IO_SourceFile
h)
++pwch;
textlen = pwch - text.wz; /* in wchar_ts */
/* textlen now contains length in wide chars */
}
#else /* WPRFLAG */
if (flags & (FL_LONG|FL_WIDECHAR))
{
size_t temp;
char tchr[MB_LEN_MAX];
if (text.wz == NULL) /* NULL passed, use special string */
text.wz = __wnullstring;
bufferiswide = 1;
pwch = text.wz;
for (textlen=0; textlen {
if ((temp = wctomb(tchr, *pwch))<=0) break;
textlen += temp;
}
/* textlen now contains length in bytes */
}
else
{
if (text.sz == NULL) /* NULL passed, use special string */
text.sz = __nullstring;
p = text.sz;
while (i-- && *p)
++p;
textlen = p - text.sz; /* length of the string */
}

#endif /* WPRFLAG */
}
break;


case _T('n'): {
/* write count of characters seen so far into */
/* short/int/long thru ptr read from args */

void *p; /* temp */

p = get_ptr_arg(&argptr);

/* store chars out into short/long/int depending on flags */
#if !LONG_IS_INT
if (flags & FL_LONG)
*(long *)p = charsout;
else
#endif

#if !SHORT_IS_INT
if (flags & FL_SHORT)
*(short *)p = (short) charsout;
else
#endif
*(int *)p = charsout;

no_output = 1; /* force no output */
}
break;


case _T('E'):
case _T('G'):
capexp = 1; /* capitalize exponent */
ch += _T('a') - _T('A'); /* convert format char to lower */
/* DROP THROUGH */
case _T('e'):
case _T('f'):
case _T('g'): {
/* floating point conversion -- we call cfltcvt routines */
/* to do the work for us. */
flags |= FL_SIGNED; /* floating point is signed conversion */
text.sz = buffer.sz; /* put result in buffer */

/* compute the precision value */
if (precision < 0)
precision = 6; /* default precision: 6 */
else if (precision == 0 && ch == _T('g'))
precision = 1; /* ANSI specified */

#if !LONGDOUBLE_IS_DOUBLE
/* do the conversion */
if (flags & FL_LONGDOUBLE) {
LONGDOUBLE tmp;
tmp=va_arg(argptr, LONGDOUBLE);
/* Note: assumes ch is in ASCII range */
_cldcvt(&tmp, text.sz, (char)ch, precision, capexp);
}
else
#endif
{
DOUBLE tmp;
tmp=va_arg(argptr, DOUBLE);
/* Note: assumes ch is in ASCII range */
_cfltcvt(&tmp,text.sz, (char)ch, precision, capexp);
}

/* '#' and precision == 0 means force a decimal point */
if ((flags & FL_ALTERNATE) && precision == 0)
_forcdecpt(text.sz);

/* 'g' format means crop zero unless '#' given */
if (ch == _T('g') && !(flags & FL_ALTERNATE))
_cropzeros(text.sz);

/* check if result was negative, save '-' for later */
/* and point to positive part (this is for '0' padding) */
if (*text.sz == '-') {
flags |= FL_NEGATIVE;
++text.sz;
}

textlen = strlen(text.sz); /* compute length of text */
}
break;

case _T('d'):
case _T(
首页 上一页 5 6 7 8 9 10 11 下一页 尾页 8/12/12
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇STL 应用之set 下一篇快速计算32位数中1的位数

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: