LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2011, 06:13 PM   #1
AlexGonzalez
LQ Newbie
 
Registered: Apr 2011
Posts: 1

Rep: Reputation: 0
Exclamation C programming question Word Count for all files in a directory


Thank you.

[SOLVED]

Last edited by AlexGonzalez; 04-07-2011 at 08:33 PM.
 
Old 04-07-2011, 08:02 PM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Why four threads, and not say, five, or three? (Is this a homework problem??)

The thread function you have, print_message_function(), does not appear to be doing too much, other than printing a message to standard out. I thought that you had other requirements: counting words, counting characters, etc.

It seems to me that it might be worthwhile to implement threads that perform each of the tasks that are required. Of course, a single-thread could do it all.

Anyhow, consider opening your files, one at a time, and starting three threads to accomplish the activities that you require. Each thread returns a "count" of something; consider returning this either via the passed in arg to the thread, or via the thread's return value. You can obtain the thread's return value using the pthread_join() function.

Good luck (with the homework).
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
variable length string using GD (word wrap, carriage return, word/character count)? frieza Programming 1 02-14-2009 05:21 PM
write a program to count files within a directory bio71 Programming 1 10-03-2008 05:36 PM
Count the number of files in a directory and sub-directories within that directory soumyajit.haldar Linux - Software 4 03-20-2007 06:22 AM
how to get count of files in a directory? hongxing Linux - Software 2 11-10-2005 09:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration