Well, letters are numbers too right? You can use rand to generate an int, you fold that number into the range 0 - 25 (or 0 - 51) and convert those to letters.
#include <iostream>
usingnamespace std;
#include <cstdlib>
#include <ctime>
int main(){
printf("\n\n");
printf("*******************************\n");
printf("** Random ASCII Generator\n");
printf("*******************************");
int n = 100;
int min = 65;//65
int max = 122;//122
printf("\n\nGenerating %u random numbers between %u and %u...", n, min, max);
int *numbers = newint[n];
for(int i = 0; i < n; i++)
numbers[i] = 0;
srand((unsigned)time(0));
for(int i = 0; i < n; i++){
int r = (rand()%(max-min)) + min;
numbers[i] = r;
}
printf(" success.");
printf("\n\nRandom numbers found:");
for(int i = 0; i < n; i++){
printf("\n\t%u:\t%c", i+1, numbers[i]);
}
printf("\n\n");
delete numbers;
return 1;
}
#include <cstdlib>
#include <ctime>
#include <iostream>
usingnamespace std;
void main()
{
srand((unsigned)time(0)); // seed randomizer
string valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-+";
int n = valid.length; // set n to be the length of valid
int m = 100; // the size of the output
char output[m + 1]; // if we want to output the char array as string, we need to have an additional element for null char ('\0')
for (int i=0; i<m; i++) // loop this m times
{
// pick a random valid character and set it as the current output character
output[i] = valid[ rand() % n ];
}
output[m] = '\0'; // set the last character to be the null char so you can print it out as a string
cout << output << endl; // this prints out the random chars
}