Jump to content

c program to remove duplicates from a string array

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
guda_rao

guda_rao

    Newbie

  • Members
  • Pip
  • 1 posts
Hello, I am totally new to c programming. I need to submit my assignment on the problem statement:

Sort an array of strings and remove duplicate values from the sorted string array. The program has to be written in "C" language. Can some one please help me with the complete code? I am a novice to C programming.

Appreciate the help and thanks in advance.

#2
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts
We won't program it for you, that's the point of having a class in programming, to learn how to do it on your own. :)

BUT... we will help. Has your class taught you how to use arrays in C? And if so, do you know that strings are nothing more than C arrays that have a null-terminating character? That's probably the start, I would try writing some pseudocode example of what you want to get accomplished, then think about how that would be done in C.
Wow I changed my sig!

#3
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
Well do you know how to make an array. If they haven't taught you this then it is a pointless exercise. :confused:

What I would do though is sort the array and then all it requires is a linear scan of the array. If arr[i] = arr[i+1] then you have found a duplicate.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
There are also some useful string functions built into C for comparing strings. That will help with both the sort and removal of duplicates.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog