[Show all top banners]

cp21
Replies to this thread:

More by cp21
What people are reading
Subscribers
:: Subscribe
Back to: Computer/IT Refresh page to view new replies
 C++

[Please view other pages to see the rest of the postings. Total posts: 22]
PAGE: <<  1 2  
[VIEWED 10426 TIMES]
SAVE! for ease of future access.
The postings in this thread span 2 pages, View Last 20 replies.
Posted on 09-24-15 7:31 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Need the program to read txt file with bunch of characters
After reading it should show most commonly used character and least common


#include
#include
#include
#include

using namespace std;

const int SIZE = 50;
char line[SIZE];

void mostFrequent(char *, int);

int main()
{
ifstream inputFile;

//Open the file
inputFile.open("c:/letter_count.txt");
if (inputFile.fail())
{
cout << "Error opening file.\n";
}
else
{
// Process the file.
}

char string[SIZE];
int length;

cin.getline(string, SIZE);
length = strlen(string);
char *stptr = string;
mostFrequent(stptr, length);

cin.get();

return 0;
}

void mostFrequent(char *ptr, int length)
{
int array[256] = { 0 };
int i;
int index = 0;
char ch;

for (i = 0; ptr[i] != '\0'; i++)
{
if (ptr[i] != ' ')
++array[ptr[i]];
}
for (i = 0; i < 256; i++)
cout << array[i];
cout << endl;

int max = array[0];
for (i = 1; i < 256; i++)

{
if (array[i] > max)

{
max = array[i];
index = i;
}
}

cout << "The most common letter occurrences "

<< static_cast(index);

}

 
Posted on 09-29-15 6:10 PM     [Snapshot: 449]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Does anyone know how to convert c to c++ prg
 
Posted on 10-05-15 8:00 PM     [Snapshot: 566]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

There is one opening for c/c++ developer, is there anyone with solid experience on it? I can refer to a company. send me email at findmeitjob@gmail.com
 



PAGE: <<  1 2  
Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 90 days
Recommended Popular Threads Controvertial Threads
What are your first memories of when Nepal Television Began?
निगुरो थाहा छ ??
TPS Re-registration case still pending ..
Basnet or Basnyat ??
Sajha has turned into MAGATs nest
NRN card pros and cons?
मन भित्र को पत्रै पत्र!
Will MAGA really start shooting people?
Top 10 Anti-vaxxers Who Got Owned by COVID
TPS Work Permit/How long your took?
काेराेना सङ्क्रमणबाट बच्न Immunity बढाउन के के खाने ?How to increase immunity against COVID - 19?
Breathe in. Breathe out.
3 most corrupt politicians in the world
Guess how many vaccines a one year old baby is given
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
चितवनको होस्टलमा १३ वर्षीया शालिन पोखरेल झुण्डिएको अवस्था - बलात्कार पछि हत्याको शंका - होस्टेलहरु असुरक्षित
शीर्षक जे पनि हुन सक्छ।
Disinformation for profit - scammers cash in on conspiracy theories
someone please tell me TPS is here to stay :(
Travelling to Nepal - TPS AP- PASSPORT
Nas and The Bokas: Coming to a Night Club near you
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters