Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Apr 2nd, 2005, 12:12 PM   #1
mmmm_strawberries
Newbie
 
Join Date: Feb 2005
Posts: 10
Rep Power: 0 mmmm_strawberries is on a distinguished road
Send a message via AIM to mmmm_strawberries
Help with sorting and counting?

Well, so far I have this program reading the first 10 words of a file. But what I need it to do is read all of the words, sort the words, count the words, and print the first and last 10 words of the unsorted, then read the first and last 10 words of the sorted. So as you can see I'm so far away. But what I need help with right now is sorting all the words. Here's the fragment of my code that reads from the file. Any suggestions?


if( myfile != NULL)
{

	for(a=0; a<10; a++)
	{
		/* Get one line */
		fgets(Buffer, 5000, myfile);
		if (!feof(myfile))
		{
			/* Break the line up into words */
			token = strtok(Buffer, delimiters);
			while (token != NULL)
			{
				puts(token);
						
				/* Get the next word */
				token = strtok(NULL, delimiters);
			}
		}
	}
	   	fclose( myfile );
}
mmmm_strawberries is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:20 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC