Thread: detecting numbers in a code of line

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    11
    yeah....suppose
    Code:
    int freq[256]; ////possible alll characters....u might restrict the limit if u r using fixed set of chars
    
    for(int i=0;i<length;i++)
     freq[(int)s.at(i)]++
    this will count the frequiences and hence u can know the frequency of each character and then give approriate error msg to the user

    Note:
    s is string
    lenght is lenght of s

    cheers

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    24
    Quote Originally Posted by jawahar View Post
    Code:
    #define MAX_CHARS 256 // possible alll characters....u might restrict the limit if u r using fixed set of chars
    
    int freq[MAX_CHARS];
    
    // memset ( freq, 0, sizeof ( freq ) );
    for ( i = 0; i < MAX_CHARS; ++i )
        freq[i] = 0;
    
    for(int i=0;i<length;i++)
     freq[(int)serial_number.at(i)]++;
    ...can't increment before initialization.
    Last edited by drrcknlsn; 01-23-2008 at 09:07 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Detecting end of LINE in text files
    By kiknewbie in forum C Programming
    Replies: 6
    Last Post: 12-09-2008, 09:34 AM
  2. ASM beginner gets 24 compiler errors on hello world...
    By Desolation in forum Tech Board
    Replies: 12
    Last Post: 06-16-2007, 10:21 PM
  3. Backgammon
    By glo in forum Game Programming
    Replies: 5
    Last Post: 10-02-2006, 10:26 PM
  4. Need help with reading numbers from the command line
    By Nterpol in forum C Programming
    Replies: 4
    Last Post: 06-01-2006, 01:40 AM
  5. SSCANF help
    By mattz in forum C Programming
    Replies: 7
    Last Post: 12-10-2001, 04:53 PM