Word sorting

This is a discussion on Word sorting within the C++ Programming forums, part of the General Programming Boards category; Hi, i need help with a couple of functions. I've got a text file with a list of words Eg. ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    3

    Word sorting

    Hi, i need help with a couple of functions.

    I've got a text file with a list of words

    Eg.
    and ant any ape apt arc are ark arm art ash ask asp ass ate ave awe awl awn

    What i need to do is remove the white space & replace each word on a newline,

    Eg.
    and
    ant
    any
    ape
    apt
    Etc......

    I have no real idea of how to accomplish this task.

    Can anyone think of a function to do this?



    TIA

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    Code:
    if ( ch == ' ' ) ch = '\n';
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Word frequency and sorting
    By zyxx_66 in forum C Programming
    Replies: 32
    Last Post: 12-17-2008, 01:30 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. please help with binary tree, urgent.
    By slickestting in forum C Programming
    Replies: 2
    Last Post: 07-22-2007, 07:55 PM
  4. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  5. Wrong Output
    By egomaster69 in forum C Programming
    Replies: 7
    Last Post: 01-28-2005, 05:44 PM

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