load a vector with the numbers you want, for this problem, 0-9. Then you can shuffle it and just go sequentially; it is now a random value in range with no duplicates. you can get fancy and fill it with iota() if you want to show off.
https://www.cplusplus.com/reference/algorithm/shuffle/
https://www.cplusplus.com/reference/numeric/iota/
after these ideas replace rand()%9 with your shuffled vector: guess = v[index++]
so if you shuffled 0,1,2,3,4 to randomly be 31042 it would produce the 'random' values 3, 1, 0, 4, 2 in that order, never duplicating. A side effect of this: the index is how many guesses you made, give or take an off by one count.
warning: line 18 is legal but does nothing at all.
best practice: initialize the value when you create it:
int sum{1}; //instead of int sum; sum = 1; or int sum = 1; prefer the {} approach
best practice: initialize everything: int guess{0};
you have to loop to print a vector.
consider
cout << "results: ";
for(...)
cout << vec[i] <<", "; //note how I padded spaces in the strings, you can do or not on that as you see fit to format the output.
after the for loop, do your cout << endl; and any finishing text.
there may be a better way to express line 28 but if it works, its fine. sometime you need a complex line here and there.
later, when you have more time, study <random>. rand() is from C and is best avoided but for now it will get the job done. you may want to call srand(time(0)); to ensure it uses different numbers every time you run it.