1. C to plain English

Hello again

Is there anybody there who could translate the following for me?
Preferably into plain English, or if not, into Eu?

The // I am taking as equiv. to our --
but things like ++ after a name ,* before a name, ->, < and && have
me beatsad

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

        // Allocate an application-defined structure to store the

        // item label and the text of each subitem.
        MYITEM *pItem = LocalAlloc(LPTR, sizeof(MYITEM));

        // Copy the first string (the label).
        pszEnd = strchr(g_achTemp, ';');
        *pszEnd = '\0';
        pItem->aCols[0] = DupString(g_achTemp);

        // Copy subsequent strings (subitems).
        for (iSubItem = 1;
                iSubItem < C_COLUMNS && pszEnd != NULL;
                iSubItem++) {
            pszStart = pszEnd + 1;

            if ((pszEnd = strchr(pszStart, ';')) != NULL)
                *pszEnd = '\0';
            pItem->aCols[iSubItem] = DupString(pszStart);
        }
---------------------------------------------------------------------------

Many grateful thanx for any help

All the best

Terry

new topic     » topic index » view message » categorize

2. Re: C to plain English

>>> Terry <terry at EDERNEY.IDPS.CO.UK> 07/28/99 09:17AM >>>
Hello again

Is there anybody there who could translate the following for me?
Preferably into plain English, or if not, into Eu?

The // I am taking as equiv. to our --
but things like ++ after a name ,* before a name, ->, < and && have
me beatsad

-----------------------

In C, ++ after a name mean increment it by 1.  So var++ in C is=20
var +=3D 1 in Eu2.1 or var =3D var + 1 in earlier versions.  Stars (*) are =
pointers, which usually are used in a way similar to the way Euphoria uses =
sequences.  Although sometimes Euphoria uses allocate, poke, and peek if =
direct memory manipulation is needed.
The arrow ( -> ) in C is the way to access a record in a structure when =
the structure variable is a pointer.  && is logical and, and || is logical =
or.  The less than sign ( < ) works the same as in Euphoria.  C's for loop =
uses three parts: init, while, increment.  It's really a bit more involved =
than that, but that's the general use of them anyway.  Hope this helps.

Michael J. Sabal

new topic     » goto parent     » topic index » view message » categorize

3. Re: C to plain English

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 message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu