Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > How to calculate the percentage of each character in a text file?

Reply
Thread Tools

How to calculate the percentage of each character in a text file?

 
 
Umesh
Guest
Posts: n/a
 
      02-01-2007
Plese help. Is there any software by which we can do that?

 
Reply With Quote
 
 
 
 
Clever Monkey
Guest
Posts: n/a
 
      02-01-2007
Umesh wrote:
> Plese help. Is there any software by which we can do that?
>

Please restate your real question in the body of your posting. Don't
rely on the text in the Subject to always be obvious.

The question you asked is:

"How to calculate the percentage of each character in a text file?"

Sounds like homework to me. What have you done so far? You are
essentially asking for a distribution of letters (and, perhaps,
punctuation) in a file, possibly in order to print a histogram and/or
report on how often such characters appears in the file.

Start by counting how many of each character you get. Compare that with
the total number of characters you have.

Hint: choose a language and post to that group only. There is some
overlap between C and C++, but they are really different beasts.
 
Reply With Quote
 
 
 
 
Umesh
Guest
Posts: n/a
 
      02-01-2007
I want to find out % of a, b, c, d ..,z in a text file. Suppose that
the text file is a story. Is there any software for this purpose?

 
Reply With Quote
 
Walter Roberson
Guest
Posts: n/a
 
      02-01-2007
In article <(E-Mail Removed) .com>,
Umesh <(E-Mail Removed)> wrote:
>I want to find out % of a, b, c, d ..,z in a text file. Suppose that
>the text file is a story. Is there any software for this purpose?


Yes, there is software for that purpose, but No, I couldn't name
any immediately.

This sort of program is trivial to write in C (or C++).

A question about your specifications: should upper and lower
case characters be treated as equivilent? Should they be
counted individually? Your specification only mentioned the
lower case letters, so should upper case letters be silently
ignored?

Should the program make some kind of attempt to determine whether
a letter is part of a word, and ignore the ones that are not?
For example, if there is a phrase that "She lives at 36-E 9th St.",
then should the 'E' be counted (36-E is not a word), should
the 't' and 'h' of '9th' be counted, should the 'S' and 't'
of 'St.' be counted?
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
 
Reply With Quote
 
Umesh
Guest
Posts: n/a
 
      02-01-2007
I need at least a solution first. Then I'll look for specifications.

Walter Roberson wrote:
> In article <(E-Mail Removed) .com>,
> Umesh <(E-Mail Removed)> wrote:
> >I want to find out % of a, b, c, d ..,z in a text file. Suppose that
> >the text file is a story. Is there any software for this purpose?

>
> Yes, there is software for that purpose, but No, I couldn't name
> any immediately.
>
> This sort of program is trivial to write in C (or C++).
>
> A question about your specifications: should upper and lower
> case characters be treated as equivilent? Should they be
> counted individually? Your specification only mentioned the
> lower case letters, so should upper case letters be silently
> ignored?
>
> Should the program make some kind of attempt to determine whether
> a letter is part of a word, and ignore the ones that are not?
> For example, if there is a phrase that "She lives at 36-E 9th St.",
> then should the 'E' be counted (36-E is not a word), should
> the 't' and 'h' of '9th' be counted, should the 'S' and 't'
> of 'St.' be counted?
> --
> "No one has the right to destroy another person's belief by
> demanding empirical evidence." -- Ann Landers


 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      02-01-2007

"Umesh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>I want to find out % of a, b, c, d ..,z in a text file. Suppose that
> the text file is a story. Is there any software for this purpose?


There probably is such a program but it most likely would be faster to write
such a program than to find, download, figure out how to use/ determine that
you *can't* use, such a program, and then use it, or start over.

Set up an array of 26 char and clear it. Then read the file,incrementing
the count in the appropriate array element when a character is received.


 
Reply With Quote
 
Dave Steffen
Guest
Posts: n/a
 
      02-01-2007
"Umesh" <(E-Mail Removed)> writes:

Please don't top post...

> I need at least a solution first. Then I'll look for specifications.


*Snort*

If you don't know the specifications of your solution, how will you
know if you have one?

I think you're in the wrong group. If you're looking for an existing
tool, you need to find a newsgroup for your platform.

----------------------------------------------------------------------
Dave Steffen, Ph.D. Disobey this command!
Software Engineer IV - Douglas Hofstadter
Numerica Corporation
dg@steffen a@t numerica d@ot us (remove @'s to email me)
 
Reply With Quote
 
Mark P
Guest
Posts: n/a
 
      02-01-2007
Umesh wrote:
> I need at least a solution first. Then I'll look for specifications.
>


That would be quite funny if it weren't written by someone who probably
intends to become a programmer. Please do humanity a favor and change
majors.
 
Reply With Quote
 
Umesh
Guest
Posts: n/a
 
      02-01-2007
For simplicity assume that all 26 inputs are in lower case. Now pl
write a program to input a text file and count number of a, b, c, ..,z
in the text file. Put is down in a output file. I'll do the rest.

Dave Steffen wrote:
> "Umesh" <(E-Mail Removed)> writes:
>
> Please don't top post...
>
> > I need at least a solution first. Then I'll look for specifications.

>
> *Snort*
>
> If you don't know the specifications of your solution, how will you
> know if you have one?
>
> I think you're in the wrong group. If you're looking for an existing
> tool, you need to find a newsgroup for your platform.
>
> ----------------------------------------------------------------------
> Dave Steffen, Ph.D. Disobey this command!
> Software Engineer IV - Douglas Hofstadter
> Numerica Corporation
> dg@steffen a@t numerica d@ot us (remove @'s to email me)


 
Reply With Quote
 
Andre Kostur
Guest
Posts: n/a
 
      02-01-2007
"Umesh" <(E-Mail Removed)> wrote in
news:(E-Mail Removed) oups.com:

> For simplicity assume that all 26 inputs are in lower case. Now pl
> write a program to input a text file and count number of a, b, c, ..,z
> in the text file. Put is down in a output file. I'll do the rest.


How much are you paying?

See the C++ FAQ, section 5.3:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.3


Short answer:

Do it yourself. If you get stuck, ask a specific question.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How do I calculate Percentage Bandwidth Utilization? Ishaam Cisco 2 04-11-2007 10:09 AM
How to calculate the percentage of each character in a text file? Umesh C++ 39 02-05-2007 11:20 AM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Tomcat, mod_jk, percentage character in URI? Stig Christiansen Java 0 09-08-2004 04:42 PM



Advertisments