getline

    0热度

    2回答

    我想在名为trajectory.txt一个简单的文件(以下简化的)看起来像这样的阅读下破坏: true true false 2 我的代码很简单,读取和存储前两行在一些变量中。 #include <string> #include <fstream> #include <sstream> #include <iostream> int main(int argc, char** a

    1热度

    1回答

    我试图从存储到字符串中的文件开始计算行的开始处的空格' '。 问题是,我不知道如何告诉std::getline()停止时发现任何字符不同于' '。 std::getline(file_input, string_target, 'Any_character_except_space');

    -1热度

    1回答

    我试图把输入变量数量的字符串和numbers.Found该解决方案link变量输入: 我想这对于数字: #include<iostream> using namespace std; int main(){ int np; while (cin>>np){ cout << np<<endl; } return 0; } 为字符串: #i

    -2热度

    1回答

    我正在尝试构建一个字符串向量。 某些字符串还包含空格。 这就是为什么我使用getline(cin,string_name)。 我的代码看起来像 for(int i=0;i<n;++i) { getline(cin, s); vec.push_back(s); } 当我正在输入 ADAM BOB JOHNSON 它取两个输入字后停止,并

    -1热度

    2回答

    我有一个多行文件,每一行都是一个字符串。 的code.txt例子: AAAAA BB33A C544W 我必须把包含在另一个文件中的一些代码,每个字符串之前。我使用的是这样的: #include <iostream> #include <fstream> #include <string> using namespace std; int main() { //the

    0热度

    1回答

    从here中摘录了示例。 相关代码: char line[chat_message::max_body_length + 1]; while (std::cin.getline(line, chat_message::max_body_length + 1)) { chat_message msg; msg.body_length(std::strle

    -1热度

    1回答

    我想在字符串中获得几行输入到一个向量(或一个数组)。我使用getline()收集字符串,并且在收集完所有行后,我希望打破while循环。我试着用“if(line.empty)”然后中断,但它不起作用。我究竟做错了什么? #include <iostream> #include <vector> #include <string> using namespace std; int mai

    0热度

    1回答

    我有一个文件,每列有6列用“,”分隔。最后一列以base 64为单位进行压缩和编码。输出文件应该是第3列和第6列(解码/解压缩)。 我试图通过 awk的-F做这个 ''“{ “回声 ”$ 6“ |的base64 - 二| gunzip解” |函数getline X;打印$ 3,X} 'OFS =',” inputfile.csv> outptfile_decoded.csv 用于第一线的结果是OK

    0热度

    1回答

    使用C++ 14。我已经阅读了许多关于这个问题的文章。 如果我在下面运行这段代码,它会跳过getline行。 #include <iostream> #include "main_menu.h" void MainMenu::AddTest() { std::string courseName = ""; std::string testName = "";

    0热度

    2回答

    我想借此函数getline()和输出它的所有迭代的总和我阅读该文件。然而,我目前的代码理念让程序崩溃。 int main() { // usual read file stuff while (!in.eof()) { string total; double balance = stod(total); getline