+ 2
could you explain how this declaration of string work ?!
static const char alphanum[] = "0123456789" "!@#$%^&*" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz";
5 Réponses
+ 1
normally we define char array as
char []={1,2,3}
but in this case they define it in unfamiliar way
+ 1
include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
static const char alphanum[] =
"0123456789"
"!@#$%^&*"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
int size = sizeof(alphanum) - 1;
int main()
{
//password length
int length = 8;
srand(time(0));
for (int i = 0; i < length; i++)
{
cout << alphanum[rand() % size];
}
return 0;
}
+ 1
in this program
and it's working