[DebugForTheBook]清单2.2使用cout的例子有错误
发布于 2006-01-22 15:46 阅读:17062 评论:0 标签:

  在书第13页,清单2.2使用cout的例子第6行为:“std::cout<<"The manipulator std::endl";”书出给出的输出为:“The manipulator endl”。我百思不得其解,“std::endl”的输出怎么是“endl”呢。

  今天把Dev-C++装好后,一运行,嘿嘿,书上错了。不知道是原作者还是翻译有问题。

  输出应该为:The manipulator std::endl。

附程序:

/*********************************************
*Developer:                     yayu;                          *
*My email:                     xieyayu@163.com                *
*Development environment:   Dev-C++ 4.9.9.0;                 *
*********************************************/

#include <iostream>
#include <stdlib.h>

//using namespace std;

int main(int argc, char *argv[])
{
 
  std::cout<<"Hello there.\n"; 
  std::cout<<"Here is 5:" << 5 << "\n";
  std::cout<<"The manipulator std::endl";
  std::cout<<"Writes a new line to the screen.";
  std::cout<<std::endl;
  std::cout<<"Here is a very big number:\t" << 70000;
  std::cout<<std::endl;
  std::cout<<"Here is the sum of 8 and 5 :\t";
  std::cout<<8+5 << std::endl;
  std::cout<<"Here is a fraction:\t\t";
  std::cout<<(float) 5/8 <<std::endl;
  std::cout<<"And a very very big number:\t";
  std::cout<<(float) 7000*7000 <<std::endl;
  std::cout<<"Yayu is a C++ programer!\n";
 
  return 0;
}