I am trying to implement a function to generate a random string consisting of only a-z characters both upper and lower case.. What is wrong with the code I wrote and how can I fix it? I am constantly getting "Segmentation fault" no matter what I try to do or change..
string random(int length)
{
string set = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
string word = "";
for (int i = 0; i < length; i++)
{
word[i] = set[rand() % 52];
}
return word;
}