word count in C programming

This is a discussion on word count in C programming within the C Programming forums, part of the General Programming Boards category; how to find and print only the first word from each line of a file using C programming...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    36

    word count in C programming

    how to find and print only the first word from each line of a file using C programming

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    1. Open the file
    2. Read a line of text
    3. Find the space
    4. Print out everything before the space
    5. Repeat steps 2-4 until the end of file is reached
    6. close the file

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    how to do your own homework?

  4. #4
    Registered User
    Join Date
    Aug 2004
    Posts
    36
    how to print everything before space??
    i have done rest

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,261
    Code:
    char *letter = sentence;
    while(*letter && *letter != ' ')
    {
      printf("%c",*letter);
      letter++;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bintree and count (withouth using template)?
    By cubimongoloid in forum C++ Programming
    Replies: 7
    Last Post: 05-24-2009, 07:22 AM
  2. word count
    By unity_1985 in forum C Programming
    Replies: 3
    Last Post: 07-29-2007, 11:34 AM
  3. Replies: 7
    Last Post: 06-16-2006, 10:23 PM
  4. word count troubles
    By Hoser83 in forum C Programming
    Replies: 13
    Last Post: 02-09-2006, 09:12 AM
  5. Replies: 5
    Last Post: 09-28-2004, 01:38 PM

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