Thread: Pls help!

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    101

    Pls help!

    I have a problems with converting strings to number,
    for example,
    one thousand nine hundred eighty three -->> 1983

    I have thought for a long long time, but couldn't think of how to do the coversion.

    At the begining, I want to assign each number, i.e. one, two, three...ten, an array like a1[] = "one", a2[] = "two"......
    that more than 10 arrays will be needed. The main problem is that I can't extract "one" in the string of words to compare. I really get stuck now, please help me. thx!!

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Someone had a pretty nice post on this same exact subject awhile ago. Perhaps someone will dig it up.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    101
    Originally posted by SilentStrike
    Someone had a pretty nice post on this same exact subject awhile ago. Perhaps someone will dig it up.
    What are the keywords should I search for??
    thx!!

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    101
    help me pls..... thx....

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    101
    no one is able to help me??

    How about this?

    #include "stdio.h"
    #include "string.h"

    #define MAXLINESIZE 1001
    #define MAXWORDSIZE 50
    #define MAXWORDNUMBER 20

    void main()
    {
    char words[MAXWORDNUMBER][MAXWORDSIZE];
    int i = 0, j = 0, k = 0, chr;

    printf( "Enter Value : " );

    /* This part is to split all words and assign each word to an array orderly */

    for( k = 0; (k < MAXLINESIZE) && ((chr = getchar()) != EOF)
    && (chr != ' '); k++ ) {

    if (chr != ' ') {
    words[i][j] = (char) chr;
    j++;
    words[i][j] = null terminate; /* I cannot type null terminate */
    }
    else {
    words[i][j] = null terminate; /* I cannot type null terminate */

    i++;
    j = 0;
    }
    }

    /* At this moment 'i' is the upper value of array 'words'.
    In other words, 'i+1' is the total no. of words you input. */

    for (k = 0; k < i + 1; k++){
    printf("%s ", words[k]);

    /* wirte the conversion program */

    }

    return;
    }

    I can't complie it.... can anyone point out the errors?
    thx!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic port scanner code .. pls help ???
    By intruder in forum C Programming
    Replies: 18
    Last Post: 03-13-2003, 08:47 AM
  2. i dont know what to do. pls. help!!!!
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 03-14-2002, 03:24 PM
  3. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 10:46 AM
  4. pls help me!!
    By hanseler in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2001, 08:46 PM
  5. Pls Help Me In This Question!!!
    By Joanna in forum Windows Programming
    Replies: 1
    Last Post: 10-20-2001, 02:05 PM