Solved

counts how many times each word occurs

Posted on 1998-10-19
4
332 Views
Last Modified: 2010-04-02
stores each word in the article in the two-dimensional array words.counts how many time each word occurs in the article
eg. a word such as 'the' presumably will occur many times in the article. store it once, but count the number of times it occurs. Print bout the stored words and their respective counts
0
Comment
Question by:wongmlai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1175533
We cannot do your homework for you.  It is unethical and grounds for removal from this site (for both you and us.)

We can answer specific questions, like you might ask your teacher.
We can review your work and offer suggestions.

So do you have specific questions or would you like to attempt the problem and post what you get done?
0
 
LVL 5

Expert Comment

by:AnswerTheMan
ID: 1175534
what's the problem ? Start counting
0
 

Expert Comment

by:hawkett092198
ID: 1175535
Look, nietod's right - but here's a start

assuming you know somthing about whichever language you are programming it in (there are loads of ways to do this) -

   * Open the file
   * Start reading characters one by one
   * Treat spaces as word separators
   * Read each word into a buffer before you store it in the array
   * Check if the word already exists (increment if it does ,or store it if not)
   * When the file ends you have finished

(which is what AnswerTheMan said in two words - 'start counting')

I figure though, that this assignment is not aproblem solving exercise, and is
actually an exercise to teach you the language - so this is not going to be much help.  Let me guess - Exams coming up, assignment due, and you've been getting red-eyes from lack of both attendance and study?
0
 
LVL 1

Accepted Solution

by:
MatthewL earned 100 total points
ID: 1175536
Hi wongmlai;

You could use strtok with a token of " " to seperate the words.
Then search for each word using strstr.  Note that you will have to parse past the the found string.

i.e.

char *curSpot;
 
 . . .

curSpot = strstr( mainString, word );
curSpot += strlen( word );

Good Luck.

Matt  

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question