Click here to Skip to main content
15,896,497 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Why "make"? Pin
Richard MacCutchan7-Feb-19 6:00
mveRichard MacCutchan7-Feb-19 6:00 
GeneralRe: Why "make"? Pin
k50547-Feb-19 7:07
mvek50547-Feb-19 7:07 
GeneralRe: Why "make"? Pin
leon de boer7-Feb-19 17:13
leon de boer7-Feb-19 17:13 
JokeRe: Why "make"? Pin
Richard MacCutchan7-Feb-19 22:19
mveRichard MacCutchan7-Feb-19 22:19 
GeneralRe: Why "make"? Pin
CPallini7-Feb-19 23:05
mveCPallini7-Feb-19 23:05 
GeneralRe: Why "make"? Pin
Dar Brett8-Feb-19 16:02
Dar Brett8-Feb-19 16:02 
GeneralRe: Why "make"? Pin
CPallini9-Feb-19 0:22
mveCPallini9-Feb-19 0:22 
Questionmemory device context coordinates Pin
Alexander Kindel6-Feb-19 12:12
Alexander Kindel6-Feb-19 12:12 
AnswerRe: memory device context coordinates Pin
mo14926-Feb-19 13:30
mo14926-Feb-19 13:30 
GeneralRe: memory device context coordinates Pin
Alexander Kindel6-Feb-19 13:44
Alexander Kindel6-Feb-19 13:44 
AnswerRe: memory device context coordinates Pin
leon de boer6-Feb-19 15:55
leon de boer6-Feb-19 15:55 
GeneralRe: memory device context coordinates Pin
Alexander Kindel7-Feb-19 23:23
Alexander Kindel7-Feb-19 23:23 
GeneralRe: memory device context coordinates Pin
leon de boer8-Feb-19 21:43
leon de boer8-Feb-19 21:43 
AnswerRe: memory device context coordinates Pin
Alexander Kindel8-Feb-19 9:22
Alexander Kindel8-Feb-19 9:22 
QuestionMenu bar on title bar of application Pin
jung-kreidler6-Feb-19 2:23
jung-kreidler6-Feb-19 2:23 
QuestionChanged CMDIChildWnd to CMDIChildWndEx: does not show anything inside the frame Pin
Dansveen4-Feb-19 2:02
Dansveen4-Feb-19 2:02 
Question_findfirst and fopen very slow Pin
cristiapi31-Jan-19 1:13
cristiapi31-Jan-19 1:13 
I have about 1800 text files in a dir and their number is slowly growing (several files in a day). The size of a file is about 40 kB.
I need to enumerate all the file with the ".states" extension, open the file, check to see if there is a line that starts with a particular sequence of 4 chars and if the line exists, I save the line in a std::vector.

I use the following code, but it takes very long time at the first run (the subsequent runs are very fast):
C++
struct _finddata_t fd; long hFile;
if((hFile=_findfirst("*.states", &fd))== -1L) return; // File not found
do {
    FILE *f= fopen(fd.name, "rS");
    while(fgets(buf, sizeof(buf), f)) {
        if(0 == _strnicmp(buf, "ABCD", 4)) {
            Save buf in a std::vector
            break;
        }
    }
    fclose(f);
} while(_findnext(hFile, &fd) == 0);
_findclose(hFile);

Is there any way to speedup the code?

If I merge all the files in a single file, I solve the problem, but I prefer to keep all the original files.
QuestionRe: _findfirst and fopen very slow Pin
David Crow31-Jan-19 3:50
David Crow31-Jan-19 3:50 
AnswerRe: _findfirst and fopen very slow Pin
cristiapi31-Jan-19 3:58
cristiapi31-Jan-19 3:58 
QuestionRe: _findfirst and fopen very slow Pin
David Crow31-Jan-19 4:23
David Crow31-Jan-19 4:23 
AnswerRe: _findfirst and fopen very slow Pin
cristiapi31-Jan-19 5:34
cristiapi31-Jan-19 5:34 
QuestionRe: _findfirst and fopen very slow Pin
David Crow31-Jan-19 6:01
David Crow31-Jan-19 6:01 
AnswerRe: _findfirst and fopen very slow Pin
cristiapi31-Jan-19 6:07
cristiapi31-Jan-19 6:07 
GeneralRe: _findfirst and fopen very slow Pin
David Crow31-Jan-19 6:14
David Crow31-Jan-19 6:14 
QuestionRe: _findfirst and fopen very slow Pin
jeron131-Jan-19 4:58
jeron131-Jan-19 4:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.