Re: C to plain English

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Wed, 28 Jul 1999 09:17:14 -0400, Terry <terry at EDERNEY.IDPS.CO.UK> wrote:

>---------------------------------------------------------------------------
>    // Read each line in the specified file.
>    for (iItem = 0;
>            fgets(g_achTemp, sizeof(g_achTemp), pfData);
>            iItem++) {

             -- increment iItem AFTER reading line ( ++iItem would mean
                increment iItem BEFORE reading line
                This is called in "C" post-incrementing or
                pre-incrementing depending the position of the ++ )
             -- sizeof is a builtin "C" function that returns the size
                of a data object ( unlike Eu's length it works on any
                data object in "C"
             -- fgets(  <--file get stream until newline, EOF, or length
                                                                requested
             -- g_achTemp, <--buffer to put in
             -- sizeof(g_achTemp), <-- number of characters requested
             -- pfData) <--where to get data ( file or stream )
>
>        // Allocate an application-defined structure to store the
>
>        // item label and the text of each subitem.
>        MYITEM *pItem = LocalAlloc(LPTR, sizeof(MYITEM));

         -- pItem is a POINTER to the type of MYITEM
         -- LocalAlloc is a function that allocates a LPTR pointer
         -- to the MYITEM structure which is of sizeof MYITEM
>
>        // Copy the first string (the label).
>        pszEnd = strchr(g_achTemp, ';');
         -- search the string for ;
>        *pszEnd = '\0';
         -- replace the ; with a zero termination
>        pItem->aCols[0] = DupString(g_achTemp);
         -- duplicate the string and place it in the MYITEM structure at
         -- aCols string starting at position zero ( this is the label )
>
>        // Copy subsequent strings (subitems).
         -- for loop format is ( intialize, test, incrementation )
>        for iSubItem = 1;
>                iSubItem < C_COLUMNS && pszEnd != NULL;
initialize-- starting with the first iSubItem (iSubItem = 1 )
test      -- test if iSubItem < C_COLUMNS && (AND)  pszEnd != (IS NOT = 0 )
                                                              NULL
>                iSubItem++)
increment -- increment iSubItem after the test ( post increment )

              { <-- this starts the main body of for loop
>            pszStart = pszEnd + 1;
          -- set pszStart to point to pszEnd + the zero at the end of line

>
>            if ((pszEnd = strchr(pszStart, ';')) != NULL)
          -- find the ; that terminates the line
>                *pszEnd = '\0';
          -- replace it with the terminating zero
>            pItem->aCols[iSubItem] = DupString(pszStart);
          -- make a dupilcate and place it in the MYITEM structure
          -- at acols[iSubItem] ( iSubItem is being incremented each
          -- we go through the for loop until we read all the items )
>        } <-- go through the for loop until one of the test conditions
               is met.

In other words you are reading the lines of data terminated by ";"
The first line being a label.
The next lines are data.
Replacing each ";" with a zero and placing them in a buffer.

I hope this helps you.
Bernie

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu