This is a follow up to my question yesterday.
I'm using a function to download a file:
void downloadFile(const char* url, const char* fname, const char* id ) {
//..
}
This is called like :
downloadFile("http://servera.com/file.txt", "/user/tmp/file.txt", "/home/user/Download/xxxx");
This works fine with a fixed id
as shown, but I need xxxx
to replaced with a random number:
srand(time(NULL));
int rdn = rand();
If I try:
downloadFile("http://servera.com/file.txt", "/user/tmp/file.txt", "/home/user/Download/" + rdn);
I get
error: invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]
So how do I append rdn
to the string "/home/user/Download/"
? For example, if rdm == 123456789
, I would like to pass "/home/user/Download/123456789"
to the function.