Loading ...
Sorry, an error occurred while loading the content.

hashes in C

Expand Messages
  • ramprasad_ap
    Hello All I have been programming for more than 2 years now . I now need to convert one of my codes to C. I am an absolute beginner and I just want to know how
    Message 1 of 4 , Aug 6, 2002
    • 0 Attachment
      Hello All
      I have been programming for more than 2 years now . I now need to
      convert one of my codes to C. I am an absolute beginner and I just
      want to know how to implement hashes in C.

      Also is there any equivalent for DB_File.pm in C

      Thanks all
      Ram
    • Dragon
      ... Depends... a hash of what type of variables? Unlike Perl, C requires you to define a type of data to be stored in a variable. Basically, you re probably
      Message 2 of 4 , Aug 6, 2002
      • 0 Attachment
        --- ramprasad_ap <ramprasad@...> wrote:
        > Hello All
        > I have been programming for more than 2 years now
        > . I now need to
        > convert one of my codes to C. I am an absolute
        > beginner and I just
        > want to know how to implement hashes in C.


        Depends... a hash of what type of variables?

        Unlike Perl, C requires you to define a type of data
        to be stored in a variable.

        Basically, you're probably looking at setting up a
        two-dimensional array. Instead of being able to use
        key/value pairs, what you'll need to do is search
        through column one of the array until you find your
        key, then use the row position where you found the key
        to know where to find the value you're wanting.

        Something like this:


        [Disclaimer: Untested code, may contain errors.
        Intended for discussion of process only]

        /* Set up a loop with the same number of iterations as
        the array has rows */
        for (iLoop = 0; iLoop < iMaxValue; iLoop++)
        {
        /* Check to see if the data in the first column
        */
        /* of this row of the array matches the Key */
        /* that we're looking for */
        if (array[iLoop][0] == KeySought)
        {
        /* Once the key is found, get the data in */
        /* the second column of the array, on that
        */
        /* same row. That is the Value that we're
        */
        /* looking for */
        ValueSought = array[iLoop][1];
        }
        }


        Hope that helps!

        __________________________________________________
        Do You Yahoo!?
        Yahoo! Health - Feel better, live better
        http://health.yahoo.com
      • Bill Gates
        Do you have a Kernighan and Ritchies C, the second edition? In section 6.6 they give you a hash function. They are also prevalent in many algorithm books.
        Message 3 of 4 , Aug 6, 2002
        • 0 Attachment
          Do you have a Kernighan and Ritchies C, the second edition? In section 6.6
          they give you a hash function. They are also prevalent in many algorithm
          books.


          >--- ramprasad_ap <ramprasad@...> wrote:
          > > Hello All
          > > I have been programming for more than 2 years now
          > > . I now need to
          > > convert one of my codes to C. I am an absolute
          > > beginner and I just
          > > want to know how to implement hashes in C.




          _________________________________________________________________
          Send and receive Hotmail on your mobile device: http://mobile.msn.com
        • frankie
          Hi all, Just a quick question... I am using the LWP module to grab a page and save it locally (as $file)... using this: my $return_query =
          Message 4 of 4 , Aug 6, 2002
          • 0 Attachment
            Hi all,

            Just a quick question...

            I am using the LWP module to grab a page and save it locally (as $file)...

            using this:

            my $return_query = "$return_URL?$query_string";
            my $result = getstore( $return_query, $file);
            unless ($result == 200) {
            print "Cannot download $return_URL : HTTP Status = $result\n";
            }

            My question is,, is there any way to get LWP to save that file as one
            line???

            I want to have the entire file made as a long single line, so I can use
            simple regex to seach the file and not have stuff missed because its over
            multiple lines..

            I know I can do it with a foreach loop.. but I was hoping that there was a
            way to avoid the extra step.


            Does anyone know of anything that would be useful to me here? or should I
            just go ahead and make it a single line buy using a foreach loop, chomping
            off the newline and appending each line to the last one...


            any tips would as always be fantastic and much appreciated.


            rgds

            Franki
          Your message has been successfully submitted and would be delivered to recipients shortly.