Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 函数来解析C++;_C++_Parsing - Fatal编程技术网

C++ 函数来解析C++;

C++ 函数来解析C++;,c++,parsing,C++,Parsing,我需要解析一个.txt文件,它包含三行,三列之间用空格分隔,数据类型如下: string size_t string 我要做的是将这三个参数保存在一个结构数组中。我的作用是: bool setInput(std::istream& input, size_t n_tx_in, input_t *inputs){ std::string line; for(size_t i=0; i< n_tx_in; i++){ getline(input,l

我需要解析一个.txt文件,它包含三行,三列之间用空格分隔,数据类型如下:

string size_t string
我要做的是将这三个参数保存在一个结构数组中。我的作用是:

bool setInput(std::istream& input, size_t n_tx_in, input_t *inputs){

    std::string line;

    for(size_t i=0; i< n_tx_in; i++){
        getline(input,line);
    }
    
}

我不知道如何分割每一行并获取这三个参数,以便将它们存储在输入数组中。我应该用什么?感谢您的帮助。

是否有助于您开始使用?字符串本身是否可以包含空格?如果不是,则正常的流提取操作符
>
将空格分隔开,默认情况下会忽略空格。换行符(
\n
)也是空白:
getline
。简而言之,
while(input>>a>>b>>c)[……记住a、b、c.}
typedef struct{
    string tx_id;
    size_t idx;
} outpoint_t;

typedef struct{
    outpoint_t outpoint;
    string addr;
} input_t;