C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 1st, 2013, 07:09 PM
Spleez Spleez is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2013
Posts: 1 Spleez User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 36 sec
Reputation Power: 0
Question General - Beginner needs help with Arrays

I'm having trouble figuring out how to code this properly. I hope someone here can help me, as my teacher is barely responsive. The assignment is as follows:

1. Prompt the user for a string (<= 100 characters).
2. Display the frequency table showing the total number of characters entered by the user, the count for each character entered by the user, and the percentage of the total count that is attributed to each character.


This is what I have so far:

Code:
#include <stdio.h>
#include <stdlib.h>


int main()
{
    char textChar;
    int textLength = 0;
    int asciiArray[128] = {0};
    int i;
    
    printf("\nEnter string 1:");
    
    while ((textChar = getchar())!= '\n') {
    textLength++;
    asciiArray[textChar]++;
    
     printf("\nFREQUENCY TABLE\n");
     printf("---------------\n");
     printf("Char Count %% of Total\n");
     printf("---- ----- ----------\n");
     
     printf(" ALL %5d %9.2f%%\n", textLength,( textLength * 100.0 ) / textLength );
    
     for (i = 0; i < 128; i++)    
    
    
getchar();
return(0);
}


I'm not sure how to get the each character individually counted and then displayed. I'm stuck and not sure where to go from here. I think I need to get the ascii values of the characters and then convert them back into character values...I think. I dunno. Any help would be greatly appreciated!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - Beginner needs help with Arrays


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap