Did you know S.A.M.? (text to speech)


Author Message
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1044
Posted: 11:19am 25 Nov 2018      

Hi Frank,

  Quote  at the same time

??

Suppose your number is in an array (a[]). I would write a function named is_pronounceable_digit (char a[], t_size index).
In this function you can examine the element a[index], if it is a single digit and not a pitch value. Much like you would do in Basic. I would do it in this way:


// untested code snipped - not complete
include <ctype.h> //some macros for isdigit() and isalpha() etc.
include <stddef.h>
#define TRUE 1
#define FALSE 0

// check if an array element is a pronounceable digit
integer is_pronounceable_digit (char a[], size_t index){
if (isdigit((int) a[index])) { // stands for (a[index] >= 48 && a[index] <= 57)
if (index){ // true if not the first character
if (isalpha((int) a[index-1]))
return(FALSE); // pitch, eg "A1" (a[index-1]+a[index])
}else{
return(TRUE);
}
}else{
return(TRUE); // the digit (a[index]) is the first character
}
}
return(FALSE);
}

(for <ctype.h> see also: https://www.tutorialspoint.com/c_standard_library/ctype_h.htm)

To complete this code we need a list of rules. I hope, this helps (I am certainly not an accomplished C programmer. ).
  Quote  (you know, I am new to C)?

BTW. there are free C interpreters to play with ...

Kind regards
Michael