vc6的printf函數結果囘卷的問題
来源:互联网 发布:淘宝上的腾讯会员账号 编辑:程序博客网 时间:2024/06/06 20:38
我寫了一個程序,其中用到了格式化輸出的問題。於是我自然而然的想到使用printf實現。但是卻沒想到,在控制臺的最後一行卻出現了問題。代碼是這樣的.
#define FMT "%s Old=%s, the new[other=exit]:"
char *p = "SecurityLevel (0=authNoPriv 1=authPriv 2=noAuthNoPriv):";
char *oldValue = "0";
int main(void)
{
...
// 在屏幕的末行
printf(FMT, p, oldValue);
{
int newValue = 0;
scanf("%d", &newValue);
}
...
}
結果是由於在合成成結果是"SecurityLevel (0=authNoPriv 1=authPriv 2=noAuthNoPriv) Old=0, the new[other=exit]:",超出了80個字符,於是乎超出的部分"xit]:",並沒有換行,而是覆蓋了行首的字符。我試了各種方法都沒有解決。最後解決方案是裁減FMT的内容,刪除方括號及其中的内容,由於内容沒有超過80個字符,所以問題就沒有出現了。也許以後有其他更好地解決辦法。這肯定是微軟VC庫的bug.
#define FMT "%s Old=%s, the new[other=exit]:"
char *p = "SecurityLevel (0=authNoPriv 1=authPriv 2=noAuthNoPriv):";
char *oldValue = "0";
int main(void)
{
...
// 在屏幕的末行
printf(FMT, p, oldValue);
{
int newValue = 0;
scanf("%d", &newValue);
}
...
}
結果是由於在合成成結果是"SecurityLevel (0=authNoPriv 1=authPriv 2=noAuthNoPriv) Old=0, the new[other=exit]:",超出了80個字符,於是乎超出的部分"xit]:",並沒有換行,而是覆蓋了行首的字符。我試了各種方法都沒有解決。最後解決方案是裁減FMT的内容,刪除方括號及其中的内容,由於内容沒有超過80個字符,所以問題就沒有出現了。也許以後有其他更好地解決辦法。這肯定是微軟VC庫的bug.
- vc6的printf函數結果囘卷的問題
- printf函数的实现vc6.0和win_tc
- 自己动手写printf -- 库函数printf的实现
- printf的一些用法
- printf的一种用法
- 由printf引起的
- printf 的简单实现
- __int64的printf问题
- printf的用法
- printf的扩展
- Printf函数的使用方法
- printf的用法(总结)
- printf的后退
- printf 的打印格式
- linux下的printf
- printf()的格式化输出
- printf的注意事项
- printf的实现
- 长风联盟缔造国产SOA新纪元
- fckeditor
- 微软One World技术研讨会归来
- static静态数据1
- mmap函数介绍
- vc6的printf函數結果囘卷的問題
- 用电动剃须刀修整衣服
- 诗文
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(18):_sdata
- FXG1.0公开规范中文简介(二)
- 获得成功人生的十句“良言佳句"(英文)
- 用不同的域名访问同一个空间上面不同的网站
- FXG1.0公开规范中文简介(三)
- 多个虚拟主机的配置问题