Results 1 to 3 of 3

Thread: Converting from char to byte

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Location
    New Zealand
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Converting from char to byte

    well a int is 4 bytes long in 32bit architecture and 8 bytes in 64bit architecture so what you should do it instead of using int is try using "unsigned char". and cast the result of qrand to "unsigned char"
    Qt Code:
    1. unsigned char n;
    2. n = (unsigned char) qrand() % 255;
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to bythos for this useful post:

    Ferric (8th January 2010)

  3. #2
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Converting from char to byte

    Did you look at quint8, quint16, quint32 or quint64? You can use quint32[4] to have you 128 bits or quint8[16] to process that byte by byte.
    -- Tanuki

    per cauda vel vaculus cauda

Similar Threads

  1. Converting QString to char* in onl line
    By hubbobubbo in forum Qt Programming
    Replies: 10
    Last Post: 11th December 2009, 11:45
  2. Converting QString to char array
    By srohit24 in forum Qt Programming
    Replies: 3
    Last Post: 22nd July 2009, 18:19
  3. problem converting string-char-int
    By mickey in forum General Programming
    Replies: 1
    Last Post: 9th December 2006, 23:43
  4. QString to char* not converting
    By DPinLV in forum Qt Programming
    Replies: 17
    Last Post: 6th August 2006, 12:15
  5. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:10

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
  •  
Qt is a trademark of The Qt Company.