From e970ec8268bae2d175a76018535220052e4f2edf Mon Sep 17 00:00:00 2001 From: mjfernez Date: Tue, 11 Feb 2020 21:00:53 -0500 Subject: still reworking wordnums --- reworking/wordnums | Bin 17296 -> 17296 bytes reworking/wordnums.c | 13 ++++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/reworking/wordnums b/reworking/wordnums index 98bbf35..8510dee 100755 Binary files a/reworking/wordnums and b/reworking/wordnums differ 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; } -- cgit v1.2.3