Archived:Creating Random Numbers in Symbian
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Article Metadata
Tested with
Devices(s): Nokia N97
Compatibility
Platform(s): S60 3rd Edition
Article
Keywords: TRandom
Created: Paul.Todd
(04 Feb 2010)
Last edited: hamishwillee
(19 Jun 2012)
Contents |
Overview
Random value generation in Symbian C++ can be done with the TRandom API. This calls into the OS to gen a pseudo random number stream based on the size of the supplied descriptor
This snippet can be self-signed.
MMP file
The following libraries are required:
LIBRARY euser.lib
Source file
#include <random.h>
int main (void)
{
// if we want 10 random bytes of data..
TBuf8<10> prngData;
prngData.SetLength( prngData.MaxLength() );
TRandom::RandomL(prngData);
// prngData now has the random data in it.
// Of course HBufC8* could be used to reduce stack space
return 0;
}
Postconditions
10 random numbers are generated


(no comments yet)