Results 1 to 2 of 2

Thread: Generating random characters

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Generating random characters

    Hi,

    Is there some way be which I can generate random alphabet (between A and Z or between a and z) ?

    Thanks a lot.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Generating random characters

    Qt Code:
    1. QString alphabet;
    2. int diff = 'Z'-'A';
    3. for(int i=0;i<alsize;i++){
    4. char c = 'A'+(rand() % diff);
    5. alphabet += QChar(c);
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to wysota for this useful post:

    munna (25th November 2006)

Similar Threads

  1. Replies: 15
    Last Post: 31st January 2020, 18:25
  2. Random no. generation using QT3??
    By darpan in forum General Programming
    Replies: 1
    Last Post: 8th August 2006, 12:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.