Thread: Words and lines count problem

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    1

    Words and lines count problem

    hi, everybody!

    I have three problems that I would like you guys to help me out with.

    But first I have to let you guys know that I'm a newbie to the c language so please be specific with the solutions that you provide.

    Ok, here we go...

    Problem 1:

    I am trying to read data from a file till EOF, count how many words and lines on that file, and then display the results onto the screen.

    Example:

    one two three four five
    six seven eight nine ten

    Problem 2:

    I want to rewrite "Problem 1" but this time it will have to read a .csv file that uses commas for delimiters instead of spaces.

    Example:

    one,two,three,four,five
    six,seven,eight,nine,ten

    Problem 3:

    I would like to rewrite "Problem 2" from above but this time it will use an array to hold the words. Its purpose is to read all the words (separated by commas) and then place each word in its own element.

    Thanx in advance,

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Forum Guidelines. Read before posting
    Homework
    Quote Originally Posted by emo
    But first I have to let you guys know that I'm a newbie to the c language so please be specific with the solutions that you provide.
    Hopefully that was just poorly worded. You provide attempts, we offer suggestions for improvement.
    Last edited by Dave_Sinkula; 07-12-2005 at 03:45 PM. Reason: Added quote, etc.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C String Problem: Not reading end of string
    By sedavis4 in forum C Programming
    Replies: 5
    Last Post: 11-17-2008, 10:29 PM
  2. Need help in debugging this code
    By jaggesh in forum C Programming
    Replies: 4
    Last Post: 02-09-2008, 08:47 AM
  3. Replies: 7
    Last Post: 06-16-2006, 09:23 PM
  4. Number of words multiplied by the number of lines in Linux
    By sjalesho in forum Linux Programming
    Replies: 2
    Last Post: 11-20-2003, 03:25 PM
  5. count only lines of code...
    By flightsimdude in forum C Programming
    Replies: 13
    Last Post: 09-23-2003, 07:08 PM