Thread: Count number of letters and numbers in a file

  1. #1
    Registered User
    Join Date
    Dec 2006

    Count number of letters and numbers in a file


    I wanted to know if there is a better way to code this situation of counting the number of occurances of each letter(case insensitive) and each number in a file, disregarding other characters. So far I have it completed by turning each line of the file into a string, than using loops, if-else logic, and isalpha and isdigit to walk through each string char by char to do this, updating as i go along. My question is there a simpler code to do this? I am fairly new to C programming. Thanks for help.

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Yes, don't bother breaking it up into lines for one.

    Without seeing how you're doing it, it's hard to say.

  3. #3
    Join Date
    Oct 2007
    Inside my computer
    I'm thinking you might need an array and some char logic to use it as a map.
    char counts[255] = {0};
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to use case/switch with letters and numbers
    By jericjones45 in forum C Programming
    Replies: 4
    Last Post: 04-23-2009, 04:38 PM
  2. need to count individual letters in input
    By epox in forum C Programming
    Replies: 12
    Last Post: 05-22-2006, 06:32 AM
  3. converting numbers to letters??
    By Lau in forum C Programming
    Replies: 5
    Last Post: 11-06-2002, 12:17 PM
  4. Convert Phone Letters To Numbers
    By nicolobj in forum C Programming
    Replies: 4
    Last Post: 10-03-2002, 03:53 PM
  5. Transforming letters to numbers...
    By N8760 in forum C++ Programming
    Replies: 2
    Last Post: 12-23-2001, 03:26 PM