Commit 95eb548b authored by Andrew Hall's avatar Andrew Hall

add some testing stuff and utils

parent 75dacbaa
#ifndef UTILS_H
#define UTILS_H
#include <stdio.h>
#include <string.h>
int strmaxlen(char **str_list, int len) {
int max_len = 0;
for (int pos = 0; pos < len; pos++) {
int l = strlen(str_list[pos]);
if (l > max_len) {
max_len = l;
}
}
return max_len;
}
int strminlen(char **str_list, int len) {
int min_len = -1;
for (int pos = 0; pos < len; pos++) {
int l = strlen(str_list[pos]);
if (l < min_len || min_len == -1) {
min_len = l;
}
}
return min_len;
}
#endif
#include <stdio.h>
#include "utils.h"
int main(int argc, char **argv) {
int i = strmaxlen(argv, argc);
printf("max len: %i\n", i);
int j = strminlen(argv, argc);
printf("min len: %i\n", j);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment