Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 13:29, 8 December 2007.

How to Generate Random Numbers

From Forum Nokia Wiki

Following Code snippet shows "How to generate random numbers" with Symbian C++ programming.

const TUint KRandomNumberSize = 6;
TBuf<KRandomNumberSize > CYrAppUi::GenerateRandom()
{
	TBuf16<KRandomNumberSize> random(_L(""));
	//Generate the random number of 6 Digits
	TInt i;
	for (i=0; i<KRandomNumberSize ; i++)
	{
		TInt num = Math::Random() % 10;
		TBuf<1> nTmp;
		nTmp.Num(num);
		random.Append(nTmp);
	}
	return random;
}

Use it as below:

TBuf<KRandomNumberSize> random(GenerateRandom());

Thus random descriptor will have 6 digits random number. User can change the value of KRandomNumberSize according to his/her needs.

Note: Do not forget to include e32math.h

Related Discussions
Thread Thread Starter Forum Replies Last Post
carbide.c++ how to generate .def file for a .dll ? aboseny Carbide.c++ and CodeWarrior Tools 1 2006-09-19 15:55
code numbers enstedt Digital Rights Management & Content Downloading 1 2002-12-13 11:18
How to generate successfully sisx formate? forwardjoy General Symbian C++ 0 2006-05-24 07:12
Question about dialog rsf Python 9 2007-10-27 03:58
downloading numbers jim371 PC Suite API and PC Connectivity SDK 0 2002-05-18 15:04
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX