Convert VB code to C code.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kenneth Osenbroch

    Convert VB code to C code.

    Hi,

    I am having trouble translating the following lines of Visual Basic
    code to C.

    For iCounter = Len(sReference) To 1 Step -1
    iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
    Next

    fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)

    Any ideas anyone? I have had some help, but I need to know how C's FOR
    loops looks like, and how "Val(Mid.." and "Right(Str. .." are
    translated into C. Any further help would be greatly appreciated.

    Thanks,
    Kenneth
  • Dave Vandervies

    #2
    Re: Convert VB code to C code.

    Hmm. Interesting, yet oddly not inappropriate, crosspost list on
    this one.

    In article <ce7df6a2.04110 21301.4d0ef87e@ posting.google. com>,
    Kenneth Osenbroch <kenneth.osenbr och@telenor.com > wrote:[color=blue]
    >Hi,
    >
    >I am having trouble translating the following lines of Visual Basic
    >code to C.
    >
    > For iCounter = Len(sReference) To 1 Step -1
    > iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
    > Next
    >
    > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)
    >
    >Any ideas anyone? I have had some help, but I need to know how C's FOR
    >loops looks like,[/color]

    You'll want to get a textbook (or somebody who knows C) for this.
    Get a basic knowledge of the language, and *then* start translating code
    into it.

    Be careful choosing textbooks, because there are a lot of bad ones
    out there. One of the best, especially if you've done some programming
    in other languages, is _The C Programming Language, 2nd edition_ by
    Kernighan and Ritchie.

    [color=blue]
    > and how "Val(Mid.." and "Right(Str. .." are
    >translated into C.[/color]

    If I'm remembering my misspent youth with the Commodore 64 correctly,
    and if VB has inherited them (from there or from a common source) without
    too many changes (or if my misremembering and VB's embrace-and-extend have
    modified them in similar ways), Val converts a string into a numeric value
    and Right takes the last N characters of a string. (The code snippet here
    also uses Mid, which takes a substring out of the middle of a string.)

    If that's incorrect, I'm sure we'll be hearing about it from somebody
    in the VB newsgroup.

    Look up sscanf for converting strings into numeric values.

    Strings in C are just arrays of characters, so you can handle substring
    operations by copying the appropriate set of characters into another
    buffer and terminating it appropriately. Be careful with what goes
    where; you need to do all the memory management yourself, which bites
    people coming from Basic-ish backgrounds with great predictability.


    dave

    --
    Dave Vandervies dj3vande@csclub .uwaterloo.ca
    He should have done something similar to what I did last week. I broke into
    his house when it was empty and turned the toilet roll around the wrong way.
    --Bill Godfrey in comp.lang.c

    Comment

    • CBFalconer

      #3
      Re: Convert VB code to C code.

      Kenneth Osenbroch wrote:[color=blue]
      >
      > I am having trouble translating the following lines of Visual Basic
      > code to C.
      >
      > For iCounter = Len(sReference) To 1 Step -1
      > iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
      > Next
      >
      > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)
      >
      > Any ideas anyone? I have had some help, but I need to know how C's
      > FOR loops looks like, and how "Val(Mid.." and "Right(Str. .." are
      > translated into C. Any further help would be greatly appreciated.[/color]

      Here in c.l.c we have no idea what those functions do. However I
      can give you a C equivalent of the for statement:

      for (iCounter = Len(...); /* initialization */
      iCounter >= 1; /* continue condition */
      iCounter--) /* loop alteration action */
      {
      /* whatever that funny statement does */
      }

      but lose the ugly hungarian notation.

      --
      Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
      Available for consulting/temporary embedded and systems.
      <http://cbfalconer.home .att.net> USE worldnet address!


      Comment

      • cr88192

        #4
        Re: Convert VB code to C code.


        "Kenneth Osenbroch" <kenneth.osenbr och@telenor.com > wrote in message
        news:ce7df6a2.0 411021301.4d0ef 87e@posting.goo gle.com...[color=blue]
        > Hi,
        >
        > I am having trouble translating the following lines of Visual Basic
        > code to C.
        >
        > For iCounter = Len(sReference) To 1 Step -1
        > iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
        > Next
        >
        > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)
        >
        > Any ideas anyone? I have had some help, but I need to know how C's FOR
        > loops looks like, and how "Val(Mid.." and "Right(Str. .." are
        > translated into C. Any further help would be greatly appreciated.
        >[/color]

        I think (mind you c's arrays are 0 based, and I don't know vb):
        for(iCounter=st rlen(sReference ); iCounter>0; iCounter--)
        iSum+=atoi(sRef erence[i-1])*iMultiplier;

        //buf is added here as a string buffer
        sprintf(buf, "%d", 10-(iSum%10));
        fReferenceCheck sum=atoi(buf[strlen(buf)-1]);

        this is just a guess (I would think the last one would have suffered from a
        type error, but afaik vb can also insert implicit coercions).



        Comment

        • cr88192

          #5
          Re: Convert VB code to C code.


          "cr88192" <cr88192@remove .hotmail.com> wrote in message
          news:a3Xhd.268$ l66.146@news.fl ashnewsgroups.c om...[color=blue]
          >
          > "Kenneth Osenbroch" <kenneth.osenbr och@telenor.com > wrote in message
          > news:ce7df6a2.0 411021301.4d0ef 87e@posting.goo gle.com...[color=green]
          >> Hi,
          >>
          >> I am having trouble translating the following lines of Visual Basic
          >> code to C.
          >>
          >> For iCounter = Len(sReference) To 1 Step -1
          >> iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
          >> Next
          >>
          >> fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)
          >>
          >> Any ideas anyone? I have had some help, but I need to know how C's FOR
          >> loops looks like, and how "Val(Mid.." and "Right(Str. .." are
          >> translated into C. Any further help would be greatly appreciated.
          >>[/color]
          >
          > I think (mind you c's arrays are 0 based, and I don't know vb):
          > for(iCounter=st rlen(sReference ); iCounter>0; iCounter--)
          > iSum+=atoi(sRef erence[i-1])*iMultiplier;
          >
          > //buf is added here as a string buffer
          > sprintf(buf, "%d", 10-(iSum%10));
          > fReferenceCheck sum=atoi(buf[strlen(buf)-1]);
          >[/color]
          and, in being distracted, made an obvious error:
          fReferenceCheck sum=atoi(&buf[strlen(buf)-1]);

          or:
          fReferenceCheck sum=atoi(buf+(s trlen(buf)-1));



          Comment

          • Frank Adam

            #6
            Re: Convert VB code to C code.

            On 2 Nov 2004 13:01:06 -0800, kenneth.osenbro ch@telenor.com (Kenneth
            Osenbroch) wrote:
            [color=blue]
            >Hi,
            >
            >I am having trouble translating the following lines of Visual Basic
            >code to C.
            >
            > For iCounter = Len(sReference) To 1 Step -1
            > iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
            > Next
            >
            > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)
            >
            >Any ideas anyone? I have had some help, but I need to know how C's FOR
            >loops looks like, and how "Val(Mid.." and "Right(Str. .." are
            >translated into C. Any further help would be greatly appreciated.
            >[/color]
            Kenneth, i didn't know that you didn't know about C. I thought you
            didn't know about VB, but now i just don't know which one you don't
            know about ? ;-p

            Perhaps my using a pointer to iterate through the string, threw you ?
            Although, on reread, i was going through the string forward, not
            backwards, so that may have played some part if it didn't work, or
            maybe i was just plain cold sober.. but TBH, i did expect that you can
            adjust that code as needed.

            What exactly is this for ? Is this a school project, or do you want it
            to just get the VB code to work in C ?
            If it's just a conversion, then lose the iterator and the for-next and
            use a pointer to go through the string. It's much cleaner.

            Anyway, the "for-next" in C is :
            for( counter = start; counter > 1; counter--)
            where 'start' in your case would be strlen(sReferen ce) or in VB
            Len(sReference) .

            Val(string) in VB returns the numeric value of a String. ie: "48"
            yields 48 as a value, not to be confused with Ascii 48 which is 0. :)
            In C, you can do that with atoi(buffer).
            value = atoi(buffer);

            Mid(buffer, start, length) picks out 'length' number of characters
            from 'buffer', starting at 'start'
            In C, that can be done with strncpy(), sprintf() etc...

            It could be made up like this :

            char* mid(buffer, start, len)
            {
            char *p, *ret;
            if (NULL != buffer)
            {
            /* should check for len and start being ok..but bugger it */
            p = &buffer[start];
            ret = malloc(sizeof(c har) * len + 1);
            if (NULL != ret)
            {
            strcnpy(ret,p,l en);
            ret[len] = '\0' /* don't remember if it terms or not */
            }
            }
            return ret;
            }


            Right$(buffer, length) returns the rightmost 'length' characters from
            'buffer'.
            A C version may be :

            char* Right(char* buffer,long len)
            {
            char* p = buffer, long blen;

            if(NULL != p)
            {
            blen = strlen(p);
            if (len < strlen(p))
            p = &buffer[blen - len];
            }
            return p;
            }
            --

            Regards, Frank

            Comment

            • Frank Adam

              #7
              Re: Convert VB code to C code.

              On Wed, 03 Nov 2004 16:37:20 +1100, fajp@xxxxoptush ome.com.au (Frank
              Adam) wrote:
              [color=blue]
              > char* mid(buffer, start, len)
              >[/color]
              This should have read :
              char* mid(char* buffer, size_t start, size_t len)
              [color=blue]
              >char* Right(char* buffer,long len)
              >[/color]
              And this being x-posted to C.L.C. i should have remembered to use
              size_t instead of longs. I'm slapping my hands as we speak.. :)

              --

              Regards, Frank

              Comment

              • Richard Bos

                #8
                Re: Convert VB code to C code.

                "cr88192" <cr88192@remove .hotmail.com> wrote:
                [color=blue]
                > "Kenneth Osenbroch" <kenneth.osenbr och@telenor.com > wrote in message
                > news:ce7df6a2.0 411021301.4d0ef 87e@posting.goo gle.com...[color=green]
                > > I am having trouble translating the following lines of Visual Basic
                > > code to C.
                > >
                > > For iCounter = Len(sReference) To 1 Step -1
                > > iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
                > > Next
                > >
                > > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)[/color][/color]
                [color=blue]
                > I think (mind you c's arrays are 0 based, and I don't know vb):
                > for(iCounter=st rlen(sReference ); iCounter>0; iCounter--)
                > iSum+=atoi(sRef erence[i-1])*iMultiplier;[/color]

                Several mistakes here.

                First of all, atoi() is not the function of choice. If sReference
                contains an value which isn't representable in int, it causes undefined
                behaviour. Use strtol() instead; it doesn't have this problem, and is
                more flexible, too. For example, it can be used to detect errors which
                the Basic code doesn't even check for.

                Second, note that the length parameter to both Mid() and Right() is 1,
                meaning that the Basic code handles single characters. This makes the C
                equivalent simpler than one would expect:

                for (counter = strlen(sReferen ce)-1; counter>=0; counter--)
                iSum += (sReference[counter]-'0') * iMultiplier;

                Note: no function calls except strlen(). Neither atoi() nor strtol() is
                even necessary. And since all members of the string are worth the same
                amount and their order doesn't matter, even strlen() can be eliminated:

                for (counter=0; sReference[counter]; counter++)
                iSum += (sReference[counter]-'0') * iMultiplier;

                Of course, the equivalent using pointers is just as valid.

                [ Next line copied here for easier reference ][color=blue][color=green]
                > > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)[/color][/color]
                [color=blue]
                > //buf is added here as a string buffer
                > sprintf(buf, "%d", 10-(iSum%10));
                > fReferenceCheck sum=atoi(buf[strlen(buf)-1]);[/color]

                The extra buffer is unnecessary. Note, again, the single character used
                to determine the end result. (Also, your version results in an int,
                while the Basic code gives a one-character string.)

                fReferenceCheck Sum = 10-iSum%10 + '0';

                That simple. Unless you want a string instead of a single char, in which
                case fReferenceCheck Sum (what _is_ it with M$ programmers and
                sesquipedalian identifiers, anyway?) needs to be at least a char[2], not
                a char, and you need to write

                fReferenceCheck Sum[0]=10-iSum%10 + '0';
                fReferenceCheck Sum[1]='\0';

                Richard

                Comment

                • cr88192

                  #9
                  Re: Convert VB code to C code.


                  "Richard Bos" <rlb@hoekstra-uitgeverij.nl> wrote in message
                  news:4188fedc.7 23327291@news.i ndividual.net.. .[color=blue]
                  > "cr88192" <cr88192@remove .hotmail.com> wrote:
                  >[color=green]
                  >> "Kenneth Osenbroch" <kenneth.osenbr och@telenor.com > wrote in message
                  >> news:ce7df6a2.0 411021301.4d0ef 87e@posting.goo gle.com...[color=darkred]
                  >> > I am having trouble translating the following lines of Visual Basic
                  >> > code to C.
                  >> >
                  >> > For iCounter = Len(sReference) To 1 Step -1
                  >> > iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
                  >> > Next
                  >> >
                  >> > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)[/color][/color]
                  >[color=green]
                  >> I think (mind you c's arrays are 0 based, and I don't know vb):
                  >> for(iCounter=st rlen(sReference ); iCounter>0; iCounter--)
                  >> iSum+=atoi(sRef erence[i-1])*iMultiplier;[/color]
                  >
                  > Several mistakes here.
                  >[/color]
                  yes, it seems there were a lot.
                  in my distraction of trying to understand the original code, it seems I
                  forgot, eg, how to use strings, or much else for that matter...

                  those fragments are emberassing, they make me look like some stupid
                  newbie...
                  [color=blue]
                  > First of all, atoi() is not the function of choice. If sReference
                  > contains an value which isn't representable in int, it causes undefined
                  > behaviour. Use strtol() instead; it doesn't have this problem, and is
                  > more flexible, too. For example, it can be used to detect errors which
                  > the Basic code doesn't even check for.
                  >[/color]
                  I usually use my own version as the standard version, eg, has problems
                  dealing with things like '0x...' in many cases.
                  [color=blue]
                  > Second, note that the length parameter to both Mid() and Right() is 1,
                  > meaning that the Basic code handles single characters. This makes the C
                  > equivalent simpler than one would expect:
                  >
                  > for (counter = strlen(sReferen ce)-1; counter>=0; counter--)
                  > iSum += (sReference[counter]-'0') * iMultiplier;
                  >[/color]
                  one could do that...
                  [color=blue]
                  > Note: no function calls except strlen(). Neither atoi() nor strtol() is
                  > even necessary. And since all members of the string are worth the same
                  > amount and their order doesn't matter, even strlen() can be eliminated:
                  >
                  > for (counter=0; sReference[counter]; counter++)
                  > iSum += (sReference[counter]-'0') * iMultiplier;
                  >[/color]
                  yes, possible.
                  however, in this case the op may no longer recognize the algo?...
                  [color=blue]
                  > Of course, the equivalent using pointers is just as valid.
                  >[/color]
                  agreed.
                  [color=blue]
                  > [ Next line copied here for easier reference ][color=green][color=darkred]
                  >> > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)[/color][/color]
                  >[color=green]
                  >> //buf is added here as a string buffer
                  >> sprintf(buf, "%d", 10-(iSum%10));
                  >> fReferenceCheck sum=atoi(buf[strlen(buf)-1]);[/color]
                  >
                  > The extra buffer is unnecessary. Note, again, the single character used
                  > to determine the end result. (Also, your version results in an int,
                  > while the Basic code gives a one-character string.)
                  >[/color]
                  yes, I had failed to take into account that printing a value 0..9 in decimal
                  and taking the last digit is equivalent to just using the value.
                  [color=blue]
                  > fReferenceCheck Sum = 10-iSum%10 + '0';
                  >[/color]
                  I was confused as to what was going on with that...
                  of course, this looks dubious as well.
                  [color=blue]
                  > That simple. Unless you want a string instead of a single char, in which
                  > case fReferenceCheck Sum (what _is_ it with M$ programmers and
                  > sesquipedalian identifiers, anyway?) needs to be at least a char[2], not
                  > a char, and you need to write
                  >
                  > fReferenceCheck Sum[0]=10-iSum%10 + '0';
                  > fReferenceCheck Sum[1]='\0';
                  >[/color]
                  dunno, 'f' makes me think 'float', but I don't know what type the op was
                  using...



                  Comment

                  • Alex Fraser

                    #10
                    Re: Convert VB code to C code.

                    "Richard Bos" <rlb@hoekstra-uitgeverij.nl> wrote in message
                    news:4188fedc.7 23327291@news.i ndividual.net.. .[color=blue]
                    > [ Next line copied here for easier reference ][color=green][color=darkred]
                    > > > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)[/color][/color]
                    >
                    > fReferenceCheck Sum = 10-iSum%10 + '0';[/color]

                    This is not equivalent if iSum % 10 is zero (produces '0' + 10 instead of
                    '0'). Instead:

                    fReferenceCheck Sum = (10 - iSum % 10) % 10 + '0';

                    Perhaps better, put a "% 10" inside the loop instead of the first one above
                    and almost arbitrary length "number strings" (I guess: barcodes) will work.

                    Alex


                    Comment

                    • anony*mouse

                      #11
                      Re: Convert VB code to C code.

                      kenneth.osenbro ch@telenor.com (Kenneth Osenbroch) wrote in message news:<ce7df6a2. 0411021301.4d0e f87e@posting.go ogle.com>...[color=blue]
                      >
                      > I am having trouble translating the following lines of Visual Basic
                      > code to C.
                      >
                      > For iCounter = Len(sReference) To 1 Step -1
                      > iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
                      > Next
                      >
                      > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)
                      >
                      > Any ideas anyone?[/color]

                      Code:
                      #include <stdio.h>
                      #include <ctype.h>
                      
                      int main(void)
                      {
                      const char* sReference  = "12dgh3456";
                      const int   iMultiplier = 11;
                      
                      float fReferenceCheckSum;
                      int   iSum     = 0;
                      int   iCounter = strlen(sReference);
                      
                      while (--iCounter >= 0)
                      {
                      iSum += isdigit(sReference[iCounter]) ?
                      (sReference[iCounter] - '0') * iMultiplier : 0;
                      }
                      
                      fReferenceCheckSum = (float) ((10 - (iSum % 10)) % 10);
                      
                      printf("fReferenceCheckSum = %.0f, iSum = %d",
                      fReferenceCheckSum, iSum);
                      
                      getchar();
                      return 0;
                      }
                      ---
                      Note: My reply address is invalid.

                      Comment

                      • MJSR

                        #12
                        Re: Convert VB code to C code.

                        rlb@hoekstra-uitgeverij.nl (Richard Bos) wrote in message news:<4188fedc. 723327291@news. individual.net> ...[color=blue]
                        > "cr88192" <cr88192@remove .hotmail.com> wrote:
                        >[color=green]
                        > > "Kenneth Osenbroch" <kenneth.osenbr och@telenor.com > wrote in message
                        > > news:ce7df6a2.0 411021301.4d0ef 87e@posting.goo gle.com...[/color]
                        > [ Next line copied here for easier reference ][color=green][color=darkred]
                        > > > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)[/color][/color]
                        >[color=green]
                        > > //buf is added here as a string buffer
                        > > sprintf(buf, "%d", 10-(iSum%10));
                        > > fReferenceCheck sum=atoi(buf[strlen(buf)-1]);[/color]
                        >
                        > The extra buffer is unnecessary. Note, again, the single character used
                        > to determine the end result. (Also, your version results in an int,
                        > while the Basic code gives a one-character string.)
                        >
                        > fReferenceCheck Sum = 10-iSum%10 + '0';[/color]

                        Somebody has already pointed out that this would be wrong if
                        iSum%10 is zero. One would have to examine the declaration of
                        fReferenceCheck Sum (or its later usage) to determine the correct
                        C; strings are automatically converted to numbers in VB (at least,
                        in my experience) and characters are represented as strings with
                        length one. So
                        fReferenceCheck Sum = (10-iSum%10)%10;
                        would be correct if fReferenceCheck Sum is a numeric variable.

                        --
                        MJSR

                        Comment

                        • John Smith

                          #13
                          Re: Convert VB code to C code.

                          Kenneth Osenbroch wrote:
                          [color=blue]
                          > Hi,
                          >
                          > I am having trouble translating the following lines of Visual Basic
                          > code to C.
                          >
                          > For iCounter = Len(sReference) To 1 Step -1
                          > iSum = iSum + Val(Mid(sRefere nce, iCounter, 1)) * iMultiplier
                          > Next
                          >
                          > fReferenceCheck Sum = Right(Str(10 - (iSum Mod 10)), 1)
                          >
                          > Any ideas anyone? I have had some help, but I need to know how C's FOR
                          > loops looks like, and how "Val(Mid.." and "Right(Str. .." are
                          > translated into C. Any further help would be greatly appreciated.
                          >
                          > Thanks,
                          > Kenneth[/color]

                          Standard C library doesn't have a function comparable to VB's mid(),
                          left() and right(). Here is a homegrown C function similar to mid():

                          /* midstr returns a substring of n
                          characters of str starting at s,
                          or remaining characters of string
                          if s+n exceeds the length of str.
                          */
                          char* midstr(char* str, int s, int n)
                          {
                          int idx, jdx, len;
                          char* mid;

                          jdx = 0;
                          len = 0;
                          while(str[jdx++] != '\0')
                          ++len;
                          if(s + n > len)
                          n = len - s;
                          jdx = 0;
                          mid = malloc(n+1 * sizeof(*mid));
                          if(mid == NULL)
                          {
                          fprintf(stderr, "malloc failed in midstr()\n");
                          exit(EXIT_FAILU RE);
                          }
                          for(idx = s; idx < s+n; ++idx)
                          mid[jdx++] = str[idx];
                          mid[n] = '\0';

                          return mid;
                          }
                          (Disclaimer: this could undoubtedly be made more efficient by a more
                          clever programmer than myself.)

                          Numeric strings can be converted to a number with any of several Std C
                          library functions. You need to do some reading about how C handles
                          strings. It's very different than in VB. C doesn't have a "string" type.
                          Essentially, strings in C are arrays of characters, terminated with a
                          NULL character.

                          C's for loops look like this (a simple example; it can get more
                          complicated):

                          for(i=0; i<20; i++)
                          {
                          /* code here */
                          }

                          This is equivalent to VB:

                          for i = 0 to 19
                          'code here
                          next i

                          where a step value of 1 is implicit.

                          -JS

                          Comment

                          • Richard Bos

                            #14
                            Re: Convert VB code to C code.

                            John Smith <JSmith@mail.ne t> wrote:
                            [color=blue]
                            > Essentially, strings in C are arrays of characters, terminated with a
                            > NULL character.[/color]

                            _Null_ character, please. Case is important. NULL is a macro expanding
                            to a null pointer constant, not a character. (void *)0 is hardly a good
                            string terminator, let alone '(void *)0'.

                            Richard

                            Comment

                            • pete

                              #15
                              Re: Convert VB code to C code.

                              Richard Bos wrote:[color=blue]
                              >
                              > John Smith <JSmith@mail.ne t> wrote:
                              >[color=green]
                              > > Essentially, strings in C are arrays of characters,
                              > > terminated with a
                              > > NULL character.[/color]
                              >
                              > _Null_ character, please. Case is important.[/color]

                              or "null character",
                              since it's not at the begining of a sentence.
                              [color=blue]
                              > NULL is a macro expanding
                              > to a null pointer constant, not a character.[/color]

                              .... and a null pointer is a pointer
                              that compares equal to a null pointer constant.

                              --
                              pete

                              Comment

                              Working...