Thread: help pls

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    9

    help pls

    char name[]="abcdefghijklmnopqrstuvwxyz0123456789";
    char password[6];
    srand (time(NULL));
    for (int i=0;i<6;i++)
    {password[i]=name[rand()%37];
    }
    cout<<"Your password is:";
    for (int y=0;y<6;y++)
    {cout<<password[y];}

    how to loop it for different length of password?

  2. #2
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    first, use [code] tags
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    1
    Try creating the array for the password on the heap.
    example:
    Code:
    int size = 0;
    char *password = NULL;
    
    cout << "Enter a size: ";
    cin >> size;
    
    password = new char[size];
    
    if(letters == NULL)
    {
      cout << "allocation failed !" << endl;
      return 1;
    }
    
    // free up memory when done
    delete [] password;
    password = NULL;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i realy need help pls...
    By kimjan in forum C++ Programming
    Replies: 6
    Last Post: 12-23-2009, 07:04 AM
  2. Basic port scanner code .. pls help ???
    By intruder in forum C Programming
    Replies: 18
    Last Post: 03-13-2003, 08:47 AM
  3. i dont know what to do. pls. help!!!!
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 03-14-2002, 03:24 PM
  4. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 10:46 AM
  5. C programming - pls pls help me
    By sally arnold in forum C Programming
    Replies: 10
    Last Post: 01-16-2002, 04:55 AM