Click here to Skip to main content
15,908,264 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to speed up copy of .txt files into arrays? Pin
Arris745-Apr-07 5:55
Arris745-Apr-07 5:55 
AnswerRe: How to speed up copy of .txt files into arrays? Pin
David Crow5-Apr-07 6:01
David Crow5-Apr-07 6:01 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
Arris745-Apr-07 6:20
Arris745-Apr-07 6:20 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
led mike5-Apr-07 6:28
led mike5-Apr-07 6:28 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
Arris745-Apr-07 7:17
Arris745-Apr-07 7:17 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
malaugh5-Apr-07 10:55
malaugh5-Apr-07 10:55 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
Arris745-Apr-07 11:14
Arris745-Apr-07 11:14 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
David Crow5-Apr-07 6:32
David Crow5-Apr-07 6:32 
Arris7 wrote:
CFile::Seek() doesn't help because actually I do not know at which line to start and finish. I just know a starting and ending date and time. So I need to read the String and to compare it with a variable.


Fair enough, but you can still do it via a simple calculation, rather than using strtok() to find each line. strtok() is slowing you down as it has to examine each character to find the one you want. Since each line of the file is 18-19 characters in length, just compare the first 13 of those.

Something like:

void main( void )
{
    char *szBuffer = "20000103\t1658\t351\n"
                     "20000103\t1659\t352\n"
                     "20000103\t1700\t350\n"
                     "20000103\t1701\t352\n"
                     "20000103\t1702\t355\n"
                     "20000104\t0900\t354\n"
                     "20000104\t0901\t352\n"
                     "20000104\t0902\t350\n";
    char *p = szBuffer;
 
    while (p != NULL && *p != '\0')
    {
        if (strncmp(p, "20000104\t0900", 13) == 0)
        {
            printf("Found it!\n");
            break;;
        }
 
        // advance to the next 'line'
        p += 18;
    }   
}



"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

"Judge not by the eye but by the heart." - Native American Proverb


GeneralRe: How to speed up copy of .txt files into arrays? Pin
Arris745-Apr-07 7:19
Arris745-Apr-07 7:19 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
PJ Arends5-Apr-07 8:00
professionalPJ Arends5-Apr-07 8:00 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
David Crow5-Apr-07 8:15
David Crow5-Apr-07 8:15 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
led mike5-Apr-07 8:54
led mike5-Apr-07 8:54 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
Arris745-Apr-07 9:20
Arris745-Apr-07 9:20 
GeneralRe: How to speed up copy of .txt files into arrays? Pin
Arris745-Apr-07 9:33
Arris745-Apr-07 9:33 
QuestionSCSI_PASS_THROUGH_DIRECT problems Pin
FoxholeWilly5-Apr-07 5:07
FoxholeWilly5-Apr-07 5:07 
QuestionWMI Pin
saisp5-Apr-07 4:48
saisp5-Apr-07 4:48 
QuestionRe: WMI Pin
David Crow5-Apr-07 6:05
David Crow5-Apr-07 6:05 
AnswerRe: WMI Pin
saisp5-Apr-07 7:04
saisp5-Apr-07 7:04 
GeneralRe: WMI Pin
David Crow5-Apr-07 7:19
David Crow5-Apr-07 7:19 
GeneralRe: WMI Pin
saisp5-Apr-07 7:51
saisp5-Apr-07 7:51 
GeneralRe: WMI Pin
David Crow5-Apr-07 8:03
David Crow5-Apr-07 8:03 
GeneralRe: WMI Pin
saisp5-Apr-07 8:11
saisp5-Apr-07 8:11 
GeneralRe: WMI Pin
David Crow5-Apr-07 8:17
David Crow5-Apr-07 8:17 
GeneralRe: WMI Pin
saisp5-Apr-07 8:21
saisp5-Apr-07 8:21 
QuestionRe: WMI Pin
David Crow5-Apr-07 8:28
David Crow5-Apr-07 8:28 

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.