I've been working on a program that generates a melody by means of some intelligent(hopefully) guessing. It compiles nicely, but I get the infamous EXC_BAD_INSTRUCTION error at runtime. I have absolutely no idea where in the code the error could be, so I'm gonna post the code here: http://pastebin.org/153678
The error occurs after scanf has stored the users input.
That's a variant array only available in C, not C++. (In C++, all normal arrays on the stack have to have a compile-time constant as its size. "length" is a variable here.)
C-guy, eh? Beware that std::vector allocates stuff on the heap. If you are in for uber-performance struggles, you can use _alloca, which is non-standard, but works in C++ as well. ;)