Pointer to Array

Discussion in 'C' started by qiqinuinaifen128, Dec 11, 2007.

  1. qiqinuinaifen128

    qiqinuinaifen128 New Member

    Dec 10, 2007
    Likes Received:
    Trophy Points:
    Co-ordinator of swimming lessons
    Home Page:
    Hi there,

    i need help for the pointer to array...Actually i have create my hash table and i can successfully get the hash key for the word i want to store, now i want to create a one dimension array and

    i use below command to create my hashtable, get the hashkey and add the word that i want to store into the hash table

    //create hash table
    Hash::Hash (int hashSize)
           this->hashSize = hashSize;
           table = new int [hashSize]
           for (int i = 0; i <hashSize; i++)table[i]=-1;
           word = new char *[hashSize];
           for (int i = 0; i <hashSize; i++)word[i]=Null;
            //and i use this command to get the hash key
    int Hash::getHashCode(char *word)
            unsigned int h = word[0]
            for(int i = 1; i <strlen(word); i++)
             h += (h*32+word[i])%hashSize;
    //store word into hash table
    woid Hash::add(char *newWord)
             int i = getHashCode (newWord);
             while (table[i] != -1) i ++;
             word[i] = new char [strlen(newWord} + 1];
             strcpy (word[i, newWord);
    [/code ]
    getHashCode("PrintfName");//get the hashkey for "PrintName"
    hash->add("PrintfName");//store the PrintName to hashtable
    After doing the above command, i have added "PrintName" in to hashtable and have a hash key of 12, and if i have set the table[12] = 12;and i crete an singer dimemsion array node[1000]

    How can i store the "PrintName" function in to the node[12],
    what command should i use in order to make table[12] point to the node[12]

    I hope that i could get help from here.

    Many Thanks For Reply

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice