相关疑难解决方法(0)

以最有效的方式逐行读取*平台特定*

我正在寻找一种最有效的方式来阅读文本文件.

考虑到所有可能的优势,例如:

代码将是平台特定的Windows操作系统

并且我正在为当前的CPU等编写一个特定的事实.

*不介意它不是多平台.

只是简单的性能问题

我怎么能以最快的方式编码,将文本文件的每一行读入结构?

说结构是:

typdef struct _FileL{
 uint lidx;
 char* lncontent;
} FileL;
Run Code Online (Sandbox Code Playgroud)

我想的是:

传递FileL上面的动态数组和文件的路径什么是最有效的方式来填充和返回给定文件的行集合?

getFileLines(char* fullPath, FileL** fileLines){
    uint linesCount = 0;// total lines
    uint curLnIndex = 0;// lines counter

    FILE* srcFL; // will hold the source file using passed fullPath

    // now read file into memory 
    //that is the only way i could think of 
    //to be able to assign lineCount used to calculate the array length
    //and also the fastest way …
Run Code Online (Sandbox Code Playgroud)

c algorithm performance file

7
推荐指数
1
解决办法
873
查看次数

标签 统计

algorithm ×1

c ×1

file ×1

performance ×1