×
Namespaces

Variants
Actions

如何在Symbian中生成随机数

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

兼容于
文章
hoolee 在 11 Feb 2010 创建
最后由 hamishwillee 在 30 May 2013 编辑

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个随机数

This page was last modified on 30 May 2013, at 07:04.
206 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.

×