diff options
Diffstat (limited to 'reworking')
-rwxr-xr-x | reworking/wordnums | bin | 17296 -> 17296 bytes | |||
-rw-r--r-- | reworking/wordnums.c | 13 |
2 files changed, 10 insertions, 3 deletions
diff --git a/reworking/wordnums b/reworking/wordnums Binary files differindex 98bbf35..8510dee 100755 --- a/reworking/wordnums +++ b/reworking/wordnums diff --git a/reworking/wordnums.c b/reworking/wordnums.c index b7c6b3f..ad57107 100644 --- a/reworking/wordnums.c +++ b/reworking/wordnums.c @@ -14,14 +14,12 @@ const char *tens[10] = {"","", "twenty", "thirty", "forty", const char *nd = "AND"; -///starting to think recursion is wrong way to go about this... int lengthOfName(char *num){ char *word; // minus 1 for null terminator int digits = strlen(num) - 1; int n = atoi(num); if(digits == 1){ - printf("here"); word = (char *) ones[n]; printf("%s\n", word); return strlen(word); @@ -40,16 +38,25 @@ int lengthOfName(char *num){ return strlen(word); } else{ + // since the input to the function expects a null terminator, an extra '\n' is needed + + /// substring would be a better way to do this char o[2]; int on; word = (char *) tens[n / 10]; printf("%s", word); o[0] = num[1]; - printf("%s\n", o); + o[1] = '\n'; on = lengthOfName(o); + //return (strlen(word) + lengthOfName(o)); return (strlen(word) + on); } } + if(digits == 3){ + word = (char *) ones[n / 100] + int t = lengthOfName( + } + // error condition return -1; } |