1

K is a value from argv[], length is computed in main

int main(int argc, char const *argv[]) {
 .
 .
 .

 int k_mer = length - k +1;
 int array_of_kmer[k_mer] = {}; 
 }
John Jonson
  • 71
  • 2
  • 4
  • 10
  • 6
    C++ doesn't have [variable-length arrays](https://en.wikipedia.org/wiki/Variable-length_array). If you need a runtime-sized "array" use [`std::vector`](http://en.cppreference.com/w/cpp/container/vector). – Some programmer dude Feb 16 '18 at 03:06

1 Answers1

6

Standard C++ doesn't have variable length arrays. Though some implementation, like gcc, might have.

To declare array you need to know number of elements at compile time:

const int size = 5;
int arr[size];

and even better

std::array<int, size> arr;

If you need variable length array a good choice for you is std::vector.

int size = calculate();
std::vector<int> v(size);
Yola
  • 18,496
  • 11
  • 65
  • 106