Search code examples
c++stringpathintsrand

C++ : String + integer path


I'm pretty new to C++, so sorry if I asked something obvious.

    srand(time(NULL));
    int randomID = (rand() % 100);

string path = "./Questions/" + randomID + ".quiz";

In /Questions there are .quiz Files that are named as random integer numbers like "1.quiz", "202.quiz", "13.quiz"

It doesn't work when I put the randomID in, how can I solve this? The Error is in German so I don't think it will help you, it just says that ".quiz" is wrong.


Solution

  • string path = "./Questions/" + to_string(randomID) + ".quiz";