I have next C++ code in VS2019 under Windows 10:
char const* const fileName = "random_StringArray_10000000";
FILE* infile;
long fileSize;
char* buffer;
size_t readBytes;
infile = fopen(fileName, "rb");
if (infile == NULL)
{
fputs("File error", stderr); exit(1);
}
fseek(infile, 0, SEEK_END);
fileSize = ftell(infile);
rewind(infile);
buffer = (char*)malloc(sizeof(char) * fileSize);
if (buffer == NULL)
{
fputs("Memory error", stderr); exit(2);
}
auto start = chrono::steady_clock::now();
readBytes = fread(buffer, 1, fileSize, infile);
auto end = chrono::steady_clock::now();
if (readBytes != fileSize)
{
fputs("Reading error", stderr); exit(3);
}
fclose(infile);
free(buffer);
auto elapsed_ms = chrono::duration_cast<chrono::milliseconds>(end - start);
cout << "Elapsed ms: " << elapsed_ms.count() << endl;
cout << "String count: " << stringCount << endl;
system("pause");
return 0;
This method used because it is fastest way to read file from disk under VS2019.
Now i need to convert char array to the string array.
random_StringArray_10000000 - UTF8 text file.
Strings lenght 8 - 120 symbols.
Hex view of this file:

0x0D 0x0A separate strings.
Which fastest way to convert char array (buffer) to the C++ string array?
std::fstreamandstd::getlinewould do all this in a couple of lines of code rather than using c functions.it is fastest way to read fileAre you sure? Have you measured it?