+ 2

could you explain how this declaration of string work ?!

static const char alphanum[] = "0123456789" "!@#$%^&*" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz";

2nd Feb 2017, 12:40 AM
Ayman Safi
Ayman Safi - avatar
5 ответов
+ 1
normally we define char array as char []={1,2,3} but in this case they define it in unfamiliar way
11th Apr 2017, 7:47 PM
Ayman Safi
Ayman Safi - avatar
+ 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; }
11th Apr 2017, 7:49 PM
Ayman Safi
Ayman Safi - avatar
+ 1
in this program and it's working
11th Apr 2017, 7:49 PM
Ayman Safi
Ayman Safi - avatar