So, I wanted to create code, that generates certain amount of random strings and prints it in file (test.txt). But those strings, generated with rand(), just repeat in this file. How can I deal with this?
using namespace std;
string h(){
srand (time(NULL));
int a=rand()%7+4;
string c;
for(int i=0;i<a;i++){
char b=rand()%123;
c+=b;
}
return c;
}
int main(){
srand (time(NULL));
int a;
cin>>a; // here we choose amount of strings in future file
ofstream n("test.txt");//opening file to print strings
for(int i=0;i<a;i++){
n << h()<<endl;
}
n.close();
}```