Dunno what I changed...

This commit is contained in:
Ognjen Milan Robovic 2023-11-03 08:25:15 -04:00
parent 91d8dd0bcd
commit 2045f178cc
2 changed files with 11 additions and 17 deletions

View File

@ -573,31 +573,25 @@ int character_compare_array (char character, char * character_array) {
return (0);
}
int character_count (char * string, int from, int to, char this, char stop) {
int character_count (char * string, char this, int from, int to, char stop) {
int count;
for (count = 0; (from != to) && (string [from] != stop); from += (int) ((to < from) ? -1 : 1)) {
count += (int) ((string [from] == this) || (this == '\0'));
}
/*
if (to < from) {
for (count = 0; to < from; --from) {
if ((string [from] == this) || (this == '\0')) {
++count;
}
if (string [from] == stop) {
break;
}
for (count = 0; (to < from) && (string [from] != stop); --from) {
count += (int) ((string [from] == this) || (this == '\0'));
}
} else if (from < to) {
for (count = 0; from < to; ++from) {
if (string [from] == this) {
++count;
}
if (string [from] == stop) {
break;
}
for (count = 0; (from < to) && (string [from] != stop); ++from) {
count += (int) ((string [from] == this) || (this == '\0'));
}
} else {
count = 0;
}
*/
return (count);
}

View File

@ -106,7 +106,7 @@ extern int character_is_hexadecimal (char character);
extern int character_compare_array (char character, char * character_array);
extern int character_count (char * string, int from, int to, char this, char stop);
extern int character_count (char * string, char this, int from, int to, char stop);
extern int string_length (char * string);