Thread: C Qustion!??!help

  1. #1
    Registered User jaxlle's Avatar
    Join Date
    Nov 2006

    C Qustion!??!help

    i am student i need to write c code....
       First[]="Ann,Bob and Bill Abraham live in Alabama."
       Second[]="Alabama is where Anne Abrahamson lives."
    i need to find the most word length that's appear in the 2 Arrays
    Output: Alabama
      char *max_equivalent_words(char *pFirst, char *pSecond){????????}
    i need some help cuz i am new with pointers by explain it will Enough

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    You can build in some way array containing comon words from 2 arrays.
    Then in the loop calculate the length of each word in this 3rd array and store the maximum value.

    You can take each word in the firast array and check if it is present in the second (strstr will help)
    If it is - calculate its lenght
    From the calculated lengths take maximum

    You can sort both arrays from longest to shortest, then start from the longest in both arrays and search first match. Its length will be what you search
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed