小编J.W*_*.W.的帖子

将向量分配给struct的向量字段

我不确定为什么会这样:

main.cpp中:

int main(int argc, char * argv[]) {
    Pwm_Info tf_info;
    tf_info = get_pwm_info(library_data, motif_name);
}
Run Code Online (Sandbox Code Playgroud)

Gen.cpp

        struct Pwm_Info {
    std::string motif_name;
    int width;
    std::vector < double > pwm;
    Pwm_Info(): motif_name(0),
    width(0),
    pwm(0) {}
}
TF_info;

Pwm_Info get_pwm_info(std::string library_data, std::string motif_name) {
    std::vector < double > double_list;
    strtk::parse(pwm_block, " \n\r", double_list);
    std::cout << double_list.size() << std::endl;

    Pwm_Info TF_info;

    TF_info.motif_name = motif_name;
    TF_info.width = n_width;

    std::vector < double > * pointer;
    std::vector < double > * pointer2;

    pointer = & TF_info.pwm; …
Run Code Online (Sandbox Code Playgroud)

c++ struct pointers vector segmentation-fault

7
推荐指数
1
解决办法
526
查看次数

标签 统计

c++ ×1

pointers ×1

segmentation-fault ×1

struct ×1

vector ×1