calibration : utilisation de la fonction parse_digit

This commit is contained in:
Ahurac 2024-02-20 15:19:56 +01:00
parent afb38673ea
commit eb0b69bef4
2 changed files with 18 additions and 5 deletions

View file

@ -14,7 +14,6 @@
* caractère nul.
* - La chaîne de caractère contient forcément des caractères non-nuls.
*/
/*
static char parse_digit(char *line, Node *digits_tree) {
if (isdigit(line[0])) {
return line[0];
@ -22,7 +21,6 @@ static char parse_digit(char *line, Node *digits_tree) {
return Node_stringToDigit(digits_tree, line);
}
}
*/
/**
* Lire tous les caractères d'une ligne :
@ -30,12 +28,16 @@ static char parse_digit(char *line, Node *digits_tree) {
* - Si aucun chiffre n'a é trouvé, retourner 0
*/
static char first_digit(char *line) {
while (line[0] != '\0' && !isdigit(line[0])) {
char current_digit = '\0';
Node *digits_tree = Node_new('\0');
while (line[0] != '\0' && !isdigit(current_digit)) {
current_digit = parse_digit(line, digits_tree);
line++;
}
if (*line != '\0') {
return *line;
if (current_digit != '\0') {
return current_digit;
} else {
return 0;
}

View file

@ -86,3 +86,14 @@ void Node_printTree(Node *root_node) {
print_node(root_node, 0);
putchar('\n');
}
/**
* Transformer une chaîne de caractères en un chiffre à l'aide d'un arbre
* n-aire
*/
char Node_stringToDigit(Node *root_node, char *string) {
(void) root_node;
(void) string;
return '\0';
}