【问题标题】:Every time new text is displayed in IRC display the new line每次在 IRC 中显示新文本时显示新行
【发布时间】:2015-10-18 04:45:09
【问题描述】:

我正在尝试这样做:

char buffer[256];
while(!buffer.getline){
    printf("%s\n",buffer);   
}
return 0;

但我无法在缓冲区上使用 getline。

有没有其他方法可以做到这一点,或者可能是使用 getline 的方法?

【问题讨论】:

    标签: c++ c++11 irc


    【解决方案1】:

    你必须使用:

    cin.getline(buffer,256);
    

    所以你的代码将是:

    #include <iostream>
    using namespace std;
    int main(){
    
    char buffer[256];
    while(cin.getline(buffer,256)){
        printf("%s\n",buffer);
    }
    return 0;
    }
    

    【讨论】:

      猜你喜欢
      • 2020-07-25
      • 1970-01-01
      • 2021-11-29
      • 2013-12-10
      • 1970-01-01
      • 1970-01-01
      • 2020-08-28
      • 2017-05-19
      • 1970-01-01
      相关资源
      最近更新 更多