![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Output number of rows inserted, updated... | kushal_cog | UNIX for Dummies Questions & Answers | 0 | 01-30-2008 03:28 AM |
| CEP as sauce for alphabet soup (Part 9): ETL | iBot | Complex Event Processing RSS News | 0 | 11-24-2007 09:41 PM |
| adding order number in the output file | happyv | Shell Programming and Scripting | 20 | 03-13-2007 01:12 AM |
| How to count number of occurrences of a "|" from a variable? | jingi1234 | UNIX for Dummies Questions & Answers | 4 | 05-06-2005 05:48 PM |
| What can i do to check that the input is all alphabet.. ? | XXXXXXXXXX | Shell Programming and Scripting | 4 | 02-19-2002 07:09 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
output the letters of the alphabet with the number of occurrences
hi,
I'm trying to create a program that will read a file and then check the file for each letter of the alphabet and then output the letter and the number of times it appears in the file, into a new file... this is what i have so far but it's not working.. if anyone could help that would be nice! thanks #include <iostream> #include <fstream> #include <string> #include <cassert> #include <cstring> #include <cmath> #include <vector> using namespace std; int main() { cout << "\n To find the number of occurrences of each letter in the alphabet in a specific file," << "enter the file name:"; string inFile; cin >> inFile; cout << "\nEnter the name of the output file:"; string outFile; cin >> outFile; ifstream fin(inFile.data()); assert (fin.is_open()); ofstream fout(outFile.data()); assert (fout.is_open()); vector<int> numoccurrences(26); int i; char letter; for(; ![]() { fin >> letter; char lowercase = tolower(letter); if ('a'<= lowercase <='z') numoccurrences[ lowercase - 'a']++; } char ch = 0; for (int i = 1; i < numoccurrences.size(); i++) { fout << ch << numoccurrences[i]; ch++; } } |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|