David Guevara
David Guevara

Reputation: 15

Getting "Killed" or "Bus error" when assigning a C++ string

I'm getting "Killed" and "Bus error" randomly when assigning a string literal to an element in an array of strings.

int length = seqLength * 20;
string encoded[numSeqs][length + 1];
string headers[length + 1];
string keys[length];
headers[0] = "name";

If I comment out the last line, it shows no error.

Just in case, the data I'm testing with is numSeqs = 1, seqLength = 42, hence, length = 8400, and I'm compiling it with g++ (g++ -lz -fopenmp main.cpp -o encoder).

Upvotes: 0

Views: 363

Answers (0)

Related Questions