×
Namespaces

Variants
Actions
Revision as of 08:48, 15 December 2011 by hamishwillee (Talk | contribs)

如何在Symbian中生成随机数

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

兼容于
文章
hoolee 在 11 Feb 2010 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

Contents

简介

我们可以通过Symbian C++中的TRandom API来生成随机数,它将基于提供的描述大小来产生一组伪随机数

该代码自签名执行

MMP文件

需要下列链接库:

LIBRARY  euser.lib

源文件

#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;
}

后记

将生成10个随机数

141 page views in the last 30 days.
×