Alternatives C++/VC++ pour la classe SplFileObject de PHP
-
11-12-2019 - |
Question
Y a-t-il un code manuel classe ou plugin VC++ disponible, identique à celui de PHP SplFileObject
?
Veuillez consulter la question https://stackoverflow.com/questions/10650864/fetching-nth-line-of-a-file/10650864#10650864.Je veux y parvenir en utilisant C++
La solution
Vous ne savez pas pourquoi vous voulez l'utiliser pour, qu'en est-il de iostreams ou de boost :: FilserSystem?
http://msdn.microsoft.com/DE-DE / BIBLIOTHE / 22Z6066F% 28V= VS.100% 29
http://www.boost.org / doc / libs / 1_49_0 / LIBS / FileSystem / v3 / doc / index.htm
mise à jour (ajout d'un exemple de code après avoir lu les commentaires):
quelque chose comme ça alors?
#include <iostream>
#include <fstream>
#include <string>
int main(int argc, char* argv[])
{
auto fd = std::fstream("veryLargeFile.txt");
if (fd.good()) {
std::string buffer;
fd.seekg(200000);
std::getline(fd, buffer);
std::cout << buffer << std::endl;
}
fd.close();
return 0;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow