从文件中读n个取数字到RArray中
来源:百度文库 编辑:神马文学网 时间:2024/04/30 09:40:41
// Reads numbers from an input file into an RArray
void CActiveBubbleSorter::ReadNumbersFromFileL()
{
// Read contents of the input file into a descriptor
RFs fs;
User::LeaveIfError(fs.Connect());
CleanupClosePushL(fs);
TFileName fileName;
TParse parse;
parse.SetNoWild( iAvkonAppUi->Application()->AppFullName(), NULL, NULL);
#if defined(__WINS__) || defined(__WINSCW__)
_LIT( KDriveLetter, "c:" );
fileName.Copy( KDriveLetter );
#else
fileName.Copy( parse.Drive() );
#endif
TFileName privatePath;
fs.PrivatePath( privatePath );
fileName.Append( privatePath );
fileName.Append( KSortDataInputFileName );
RFile file;
User::LeaveIfError(file.Open(fs, fileName, EFileStreamText | EFileRead));
CleanupClosePushL(fs);
TInt sz = 0;
User::LeaveIfError(file.Size(sz));
HBufC8* buf = HBufC8::NewLC(sz);
TPtr8 ptr = buf->Des();
User::LeaveIfError(file.Read(ptr));
// Extract numbers from the descriptor containing the contents of the input file
TLex8 lx(ptr);
TBool finshed = EFalse;
while (!finshed)
{
if (lx.Eos())
{
finshed = ETrue;
}
else if ((lx.Peek()).IsDigit())
{
TInt num;
TInt err = lx.Val(num);
iNumbersArray.Append(num);
}
else
{
lx.Inc();
}
}
// automatically closes fs and file
CleanupStack::PopAndDestroy(3);
}
void CActiveBubbleSorter::ReadNumbersFromFileL()
{
// Read contents of the input file into a descriptor
RFs fs;
User::LeaveIfError(fs.Connect());
CleanupClosePushL(fs);
TFileName fileName;
TParse parse;
parse.SetNoWild( iAvkonAppUi->Application()->AppFullName(), NULL, NULL);
#if defined(__WINS__) || defined(__WINSCW__)
_LIT( KDriveLetter, "c:" );
fileName.Copy( KDriveLetter );
#else
fileName.Copy( parse.Drive() );
#endif
TFileName privatePath;
fs.PrivatePath( privatePath );
fileName.Append( privatePath );
fileName.Append( KSortDataInputFileName );
RFile file;
User::LeaveIfError(file.Open(fs, fileName, EFileStreamText | EFileRead));
CleanupClosePushL(fs);
TInt sz = 0;
User::LeaveIfError(file.Size(sz));
HBufC8* buf = HBufC8::NewLC(sz);
TPtr8 ptr = buf->Des();
User::LeaveIfError(file.Read(ptr));
// Extract numbers from the descriptor containing the contents of the input file
TLex8 lx(ptr);
TBool finshed = EFalse;
while (!finshed)
{
if (lx.Eos())
{
finshed = ETrue;
}
else if ((lx.Peek()).IsDigit())
{
TInt num;
TInt err = lx.Val(num);
iNumbersArray.Append(num);
}
else
{
lx.Inc();
}
}
// automatically closes fs and file
CleanupStack::PopAndDestroy(3);
}
从文件中读n个取数字到RArray中
bash脚本中取文件路径(文件名)
asp取动态表单中数据并写入xml文件
PDF文件中利用金山词霸进行屏幕取词- -
c与java中取精确到毫秒的时间
从richeditctrl中按“\n”换行显示
黑客从ATM中闪电偷取900万美元
从“豪华小学”中“读”到什么?(人民时评)
没有字符映射表(安装盘中取文件) - 已解决 - 搜搜问问
中国政改:从“邓三条”到“温四条”
从用户中来,到用户中去
从图表中来 到图表中去·哑铃
周鸿祎:从用户中来,到用户中去
邱晓华:让“人”从数字中站立起来
从数据库中随机抽N条记录
恢复从回收站中被删除的文件的方法
恢复从回收站中被删除的文件的方法
从Word和Excel文件中提取Flash
恢复从回收站中被删除的文件的方法
日本企业变相探取中国稀土 从废玻璃中提取
日本企业变相探取中国稀土 从废玻璃中提取
三、FLASH调用外部文件----调用外部*.swf文件(加载到场景中)(7) - Qzo...
vba如何实现将一个EXCEL文件中(关闭的文件)的SHEET页复制到当前的EXCEL中
记忆中成就“美女”的N个瞬间