首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

getline的有关问题

2012-05-22 
getline的问题本人菜鸟,发现程序运行并未按照编写代码的意图,即:输入quotation,回车一次,窗口提示输入spea

getline的问题
本人菜鸟,发现程序运行并未按照编写代码的意图,即:输入quotation,回车一次,窗口提示输入speaker,然后键入speaker,回车,窗口显示输入的全部内容。 程序执行时,输入quotation之后,要回车两次才出现下一行提示;且程序直接执行到最后。。。。。。。
我那行代码cin.get();没有作用了 反复改动过发现是getline的问题 请各位大神明示~~
[code=C/C++][/code]
#include <iostream>

#include <string>

using namespace std;

int main(){

  //declaring the necessary variables  
  string quote, speaker;
   
  //prompt user for quotation
  cout << " please enter the quotation:\n";
  getline(cin, quote);

  //promt user for the quote's author
  cout << "enter the person to whom this quote is atrributed:\n";
  getline(cin, speaker);
  
  cout << "\n\n";

  cout << "press enter or return to continue.\n";
  cin.get();

  return 0;

}


[解决办法]
我这里是好的
[解决办法]
我这也是好的。
[解决办法]
远离VC6,珍爱生命。

热点排行