C++ random access program