The function "randmG" will generate random letters.
I made this using dev c++, so if you're using Visual then some stuff might be different, I dunno.
I'm still learning C++, so this might not be a good way of generating a random string. So if you know more >>, tell me what I should improve on or w/e.
Code:
#include <cstdlib>
#include <iostream>
#include <string.h>
using namespace std;
string randmG(int lenght);
int main(int argc, char *argv[])
{
string randm;
int lent;
cout << "Please enter how long the random string should be:";
cin >> lent;
randm = randmG(lent);
cout << "Random string generated: " << randm << endl;
cout << "Press enter to exit.."<< endl;
cin.get();
cin.get();
return 0;
}
string randmG(int lenght)
{
string G;
int i = 0;
int n;
srand(time(NULL));
for(n=0; n<lenght; n++)
{
i = rand() % 26;
G += (char)(i+65);
}
return G;
}