ChinaUnix.net
相关文章推荐:

cout默认输出形式

int i = 5; printf("%03d\n", i); 用cout怎么实现上述格式输出呢?

by chzht001 - C/C++ - 2006-09-22 16:47:40 阅读(13968) 回复(6)

相关讨论

double i = 6752220; cout << i << endl; 会输出一个科学表达的形式。 i的可能值为整数,浮点数(小数点后顶多五位) 现在要求,不管i带几个小数点,是不是整数。 都要原样输出,即: 1》要避免科学表达方式 2》要避免输出不必要的零,最后一个数不能是零。 请问怎么做到。 我试了一些方法,都有点问题。 double i = 6752220; cout.precision(5); cout << fixed << i << endl; 总是精确到小数点后五位,整数也带了五个零。

by xiao_potato - C/C++ - 2004-09-24 00:11:21 阅读(1077) 回复(2)

#include using namespace std; int main(){volatile int i = 0; volatile float ic = 0; volatile double iv = 0;cout<<&i<<" "<<&ic<<" "<<&iv<输出地址都为1? 小弟新手,还请大虾指点~~警告信息如:warning C4305: 'argument' : truncation from 'volatile int *__w64 ' to 'std::_Bool' [ 本帖最后由 Anno_Domini 于 2009-4-8 12:38 编辑 ]

by Anno_Domini - C/C++ - 2009-04-10 10:47:41 阅读(14986) 回复(36)

有如下代码: #include using namespace std; string test_func(string a, string b) { cout << "This is in the second string test_func" << endl; return a+b; } int main() { cout << "Call test_func" << test_func("www.younet.com ", "you can get information") << endl; return 0; } 编译输出的结果是这样: This is in the second string test_func Call test_funcwww.younet.com you...

by yourantianya - C/C++ - 2006-12-18 11:35:02 阅读(3805) 回复(12)

如何用cout格式化输出double型数据,使其每行按小数点对齐。 例如:和printf("%8.2lf", d); 具有相同功能的cout语句是什么? [ 本帖最后由 sdupoplar 于 2006-9-21 12:14 编辑 ]

by sdupoplar - C/C++ - 2006-09-21 13:18:01 阅读(18338) 回复(4)

我用cout将一个整型数以16进制输出,但是我如果用 [code]cout<<"hex a="<cout.setf(ios::hex); cout<<"hex a = "<输出的数据仍然是十进制。请教大虾这应该怎么办? 多谢!!!

by jiazhengw - C/C++ - 2006-04-28 15:45:29 阅读(5753) 回复(10)

Redhat Linux AS3.0用g++323编译但while循环后再也无法输出信息,以下代码就无法输出后面的“*******”,而用C确没问题。 #include extern char** environ; using namespace std; int main() { int i(5); char** var=environ; while(*var)//while(*var++) cout<<*var++<cout<<*var<cout<<"************"<cout输出NULL会导致它无法输出,各位大侠见笑了,呵呵。...

by robinchris - C/C++ - 2006-05-31 10:36:17 阅读(1511) 回复(7)

请问这个字符流怎么用cout 输出 (const char**)result 这是个字符串数组

by nudt_lily - C/C++ - 2009-02-02 17:25:38 阅读(2471) 回复(7)

我是这么做的: cout << setw(2) << setfill ('0') << hex << (int)yccBuf << ' '; yccBuf,是char型的 。 但是0x99成了ffffff99 。 [ 本帖最后由 csoapy 于 2007-1-27 14:52 编辑 ]

by csoapy - C/C++ - 2008-06-14 13:17:47 阅读(9624) 回复(6)

今天在測試編譯器對字節對其的油畫的時候發現: #include using namespace std; int main() { double d = 0.0; int a = 1; char c = 'c'; cout << &d << endl << &a << endl << &c << endl; cin >> a ; return 0; } 輸出和預期不符。。

by DraculaW - C/C++ - 2006-09-12 14:12:24 阅读(1005) 回复(2)

真的是太奇怪了!!! 测试代码如下:     const int j = 99;     int *k;     k = const_cast(&j);     *k = 50;     std::cout<

by GodPig - C/C++ - 2009-05-26 15:04:52 阅读(2602) 回复(5)