GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Dec-2007, 07:38
Falcone Falcone is offline
New Member
 
Join Date: Sep 2007
Posts: 19
Falcone is an unknown quantity at this point

Help, building this program idea


Anyway you can help me building this program?

Write and test a program that reads a file containing text and
1) counts the number of words in the test file,
2) counts the number of each different character in the file, and
3) copies the text file to the screen along with the counts.

Use any method you know to read the text file.
Use C++ standard string class to hold text from the file.
Remember that if s is a C++ string then s[i] is one of its char's.
If ch is a char, then (int)ch is an int.
A word is what the operator << reads.
You can use an array of int to count as follows:
++a[i] counts occurrences of i if a[] is initialized to 0's.
  #2  
Old 04-Dec-2007, 08:44
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 452
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Help, building this program idea


Go ahead and post your code and any specific questions. We're not here to do all of your assignment for you. You should at least try to start it yourself. We will help you if you get stuck.
  #3  
Old 05-Dec-2007, 19:12
Falcone Falcone is offline
New Member
 
Join Date: Sep 2007
Posts: 19
Falcone is an unknown quantity at this point

Re: Help, building this program idea


anyone no how to build this?
  #4  
Old 06-Dec-2007, 01:38
inevitable inevitable is offline
Junior Member
 
Join Date: Nov 2007
Posts: 53
inevitable is on a distinguished road

Re: Help, building this program idea


To make your life little easier, plan your code something like this.
1) First write a program to count no of words in the file
2) Write Quick sort algorithm
3) Write a program to identify no of different characters using quick sort algorithm
4) Then you can easily write the program to count for unique character in the test file.

You can further breakdown the steps to complete it. You can then ask for help in each of the breakdown structure.
  #5  
Old 06-Dec-2007, 02:50
ahbi82 ahbi82 is offline
Member
 
Join Date: Jul 2006
Posts: 114
ahbi82 will become famous soon enough

Re: Help, building this program idea


Quote:
Originally Posted by Falcone
Anyway you can help me building this program?

Write and test a program that reads a file containing text and
1) counts the number of words in the test file,
2) counts the number of each different character in the file, and
3) copies the text file to the screen along with the counts.

Use any method you know to read the text file.
Use C++ standard string class to hold text from the file.
Remember that if s is a C++ string then s[i] is one of its char's.
If ch is a char, then (int)ch is an int.
A word is what the operator << reads.
You can use an array of int to count as follows:
++a[i] counts occurrences of i if a[] is initialized to 0's.

Looks like you are setting an assignment for GID members....!!! Hellya

How many marks is the assignment dube.
  #6  
Old 06-Dec-2007, 13:22
Falcone Falcone is offline
New Member
 
Join Date: Sep 2007
Posts: 19
Falcone is an unknown quantity at this point

Re: Help, building this program idea


Last one of the year for me, just tryna get threw a class that I have to take for a gen ed class. And to be honest its probably the hardest class I have taken all year.
  #7  
Old 06-Dec-2007, 13:38
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 452
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Help, building this program idea


Classes like these are really hard when you never attempt to write a single piece of code yourself. Hopefully for your sake, they do not have a final exam.
  #8  
Old 07-Dec-2007, 06:14
davis
 
Posts: n/a

Re: Help, building this program idea


Quote:
Originally Posted by Falcone
anyone no how to build this?

Yes.


:davis:
  #9  
Old 07-Dec-2007, 08:18
Falcone Falcone is offline
New Member
 
Join Date: Sep 2007
Posts: 19
Falcone is an unknown quantity at this point

Re: Help, building this program idea


Do you think you could show me a start or something?
  #10  
Old 07-Dec-2007, 08:39
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 452
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Help, building this program idea


Here is a good start:
CPP / C++ / C Code:
string LoadFile( string sFileName )
{ // TODO: load the entire file into a string and return it
}

int CountWords( string s )
{ // TODO: count all of the words in the file and return the integer
}

void PrintCharacterCounts( string s )
{ // TODO: print each character with its count next to it
}

int main()
{ // 1) Read the entire file into a string object
  string sFile = LoadFile("MyFile.txt");

  // 2) Count the words of the file
  int iWordCount = CountWords( sFile );
  
  // 3) Print out the number of each character in the file
  PrintCharacterCounts( sFile );

  // 4) Print out the file to the screen
  cout << sFile;

  return 0;
}

Now, we expect you to attempt to write each of these functions yourself. Then, when you can't figure something specific out, we'll try to help you. Please don't reply with a message like "How do I write this function? Please write it for me."
 
 

Recent GIDBlogFlickr uploads of IA pictures by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two-Tier data dissemination code installation problem nidhibansal1984 Computer Software Forum - Linux 6 16-Sep-2007 10:13
Help with C program Idea JBfox C Programming Language 15 20-Feb-2007 13:24
BOOKEEPING program, HELP!! yabud C Programming Language 10 17-Nov-2006 03:48
I have no Idea how to program yumaslim C Programming Language 10 30-Sep-2005 08:44
a pc building program in C latro C Programming Language 2 18-May-2005 03:13

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:25.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.