×
Namespaces

Variants
Actions

Archived:Creating Random Numbers in Symbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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
S60 3rd Edition (initial release)
Article
Keywords: TRandom
Created: Paul.Todd (04 Feb 2010)
Last edited: hamishwillee (18 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


This page was last modified on 18 June 2012, at 23:23.
68 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×