re string search

Posted on 1998-04-09
Medium Priority
Last Modified: 2010-04-15
out of shere time constraint I'll repost my updated querey      I need to call a function form main, my f/p is
void CountLetters(string, length, freq[], SIZE)
string is my string*, length is the size freq is an array[26] size#26
I need to be able to search through the string find the count of each letter and assign into corrospontding space in the array ie freq[0]= # of a's, freq[1] = # of b's both upper and lowers.
I need the array set up that way so I can sort it with anther array that contains the alphabet, need to be able to count the letters and put the values in the array freq
Question by:hkaufm2

Expert Comment

ID: 1258048
Are you wanting examples of how to do the letter counting? or maybe the sorting??  A little more clearity would help.  thanks

Author Comment

ID: 1258049
Edited text of question
LVL 16

Expert Comment

ID: 1258050
Hasn't this been answered under "string search"? If not, how is this question different?
LVL 10

Accepted Solution

rbr earned 150 total points
ID: 1258051
void Count_letters (char *string,int length,int *count,int size)
   int i;
   int ch;
   memset (count,0,sizeof(int)*size);

      for (i=0;i<length;i++) {
             if (isalpha(ch) {
                  ch = tolower(ch)-'a';
           if (ch < size)
                     count [ch]++;

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question