FGETS from text to array

This is a discussion on FGETS from text to array within the C Programming forums, part of the General Programming Boards category; Originally Posted by smokeyangel Sorting is a good idea! I think for a data set of this size you probably ...

  1. #31
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,703
    Quote Originally Posted by smokeyangel View Post
    Sorting is a good idea! I think for a data set of this size you probably won't lose or gain a lot by doing it one way over the other, but for llarger amounts of input data you probably should be thinking of alternatives to re examining all the elements in nArray.
    I think the ideas are very different. My advice was:
    Quote Originally Posted by whiteflags View Post
    If you sort the words, any duplicates will be adjacent to each other. So finding unique word(s) is a matter of stepping through the list, comparing each word with every other word. You should end up with a list of unique words.
    Because he said:
    Quote Originally Posted by Oonej View Post
    trying to find unique words but my logic is flawed again, any tips?
    Now I took that to mean that out of a list like, ("cat", "planet", "factory", "factory", "factory") the list of unique words should be ("cat", "planet"). But you could certainly make a different list of unique words by removing repeated words, and that might be what is meant. But if you compare every word with every other word, you can find the list I just gave. It's simple logic -- if the first occurrence of the word is the only occurrence, then it is unique. (Sorting is intended to be a bit of a speedup, but I have to admit that it could end up being more trouble than it is worth.)

    ETA: cat planet
    Last edited by whiteflags; 07-10-2011 at 01:50 AM. Reason: cat planet

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fgets() & Fputs() to combine text files?
    By d2rover in forum C Programming
    Replies: 5
    Last Post: 11-20-2010, 02:58 PM
  2. need help with char array and fgets
    By fr0zen in forum C Programming
    Replies: 25
    Last Post: 12-07-2007, 03:46 AM
  3. Replies: 3
    Last Post: 10-15-2005, 09:13 AM
  4. fgets array size
    By stautze in forum C Programming
    Replies: 9
    Last Post: 04-29-2002, 01:25 PM
  5. help chack for array and fgets
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 01-16-2002, 07:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21