You probably forgot what you did in your original code.
string path = "\"C:\\Documents and Settings\\My Documents\\";
You need to encompass the address in quote marks, which means escaping them. Note the final quote will be after the extension so your code would be like this
string path = "\"C:\\Documents and Settings\\Music\\My Documents\\";
path += (rand()%5+1)+'0';
path += ".jpg\"";
system(path.c_str());
The segmant of code you asked about generates a number between 1 and 5, which i'm sure you are aware about. But since we wish to add the character value of that number to the string not the numerical value, we need to increaes its ascii code by 48 or '0' so that we get its character value. If that makes sense, try removing the +'0' and see what happens :P You'll get a bit of a surprise.
Chris