The problem is that yours is cempty, because it was initialized without elements, not to mention an unnecessary call clear(). std::merge()takes an output iterator as the last argument. If it c.begin()refers to the beginning std::vector, which already contains enough elements, then this is not a problem - these elements will simply be overwritten. Be that as it may, you invoke undefined behavior by writing values to memory beyond the end of the vector.
c , :
c.resize(a.size() + b.size());
std::merge(a.begin(), a.end(), b.begin(), b.end(), c.begin());
std::back_insert_iterator, , push_back(). reserve() . , c , std::merge(). :
#include <iterator>
c.reserve(a.size() + b.size());
std::merge(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(c));