小编joh*_*hny的帖子

Linux中std :: cout的奇怪行为

我试图for使用2个嵌套循环打印结果std::cout.但是,结果不会立即打印到控制台,但会有延迟(在循环或程序完成后).

我不认为这种行为是正常的,在Windows打印下工作正常.该程序不使用线程.

哪里可能是问题?(Ubuntu 10.10 + NetBeans 6.9).

c++ printing cout

1
推荐指数
1
解决办法
2793
查看次数

C++,与g ++相等

Why this condition is never true ? Both parts of the equation are integers, so there must be equality for index = 0, 10, 20, 30, 40. I am compiling this code using g++.

for(int index = 0; index < 50; index++){

        if ( (int) (10 * (  0.1 * index)  ==  (int)(10 * ( int ) ( 0.1 * index ) ) ) )
        {
                 std::cout << "equal";
        }
}
Run Code Online (Sandbox Code Playgroud)

使用MSVS 2010编译器,这些问题不会发生......

  0  0
  1  0
  2  0
  3 …
Run Code Online (Sandbox Code Playgroud)

c++ equality g++

0
推荐指数
1
解决办法
186
查看次数

标签 统计

c++ ×2

cout ×1

equality ×1

g++ ×1

printing ×1