background image

  不禁又想,C++中引入了新的 iostream 流库,它又是怎样处理这个问题的呢?于是做
了下面的实验:

以下是引用片段:

  #include  
  using namespace std; 
  int main() 
  ...{ 
  char a, b; 
  cout << "Please input the first character:"; 
  cin >> a; 
  cout << "Please input the second character:"; 
  cin >> b; 
  cout << a << "," << b; 
  return 0; 
  }

  当输入 a 回车,输入 b 回车时,运行结果如下:

  当连续输入多个字符时,运行结果如下:

  可见,C++中的标准输入流已经对于换行符做了处理,看来在 C++中利用标准输入
处理特殊字符要自己做一些工作了