Compare a list of strings: Difference between revisions
Content added Content deleted
(→{{header|C}}: reduce number of variables, fix types, sprinkle const) |
|||
Line 537: | Line 537: | ||
=={{header|C}}== |
=={{header|C}}== |
||
<lang c>#include < |
<lang c>#include <stdbool.h> |
||
#include <string.h> |
#include <string.h> |
||
static bool |
|||
strings_are_equal(const char **strings, size_t nstrings) |
|||
{ |
{ |
||
for (size_t i = 1; i < nstrings; i++) |
|||
int result = 1; |
|||
⚫ | |||
return false; |
|||
while (result && (--nstrings > 0)) |
|||
⚫ | |||
{ |
|||
result = !strcmp(*strings, *(strings+nstrings)); |
|||
} |
|||
⚫ | |||
} |
} |
||
static bool |
|||
strings_are_in_ascending_order(const char **strings, size_t nstrings) |
|||
{ |
{ |
||
for (size_t i = 1; i < nstrings; i++) |
|||
int result = 1; |
|||
⚫ | |||
int k = 0; |
|||
return false; |
|||
⚫ | |||
while (result && (++k < nstrings)) |
|||
{ |
|||
⚫ | |||
} |
|||
⚫ | |||
}</lang> |
}</lang> |
||