Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctype.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include "source.h"
- int read_lines(char *filename, char ***array, int size) {
- FILE* file = fopen(filename, "r");
- if (file == NULL) {
- return -1;
- }
- size_t len = 0;
- ssize_t nread;
- int lines = 0;
- char* line = (char*) malloc(sizeof (file));
- array = (char**) malloc((size) * sizeof (char**));
- while ((nread = getline(&line, &len, file)) != -1) {
- array = realloc(array, (size + 1) * sizeof (char*));
- array[lines] = line;
- size = size + 1;
- lines++;
- }
- array = realloc(array, (size + 1) * sizeof (char*));
- array[lines] = NULL;
- return lines;
- }
- int shortest_string(char **array, int len) {
- return -1;
- }
- int find_lexi_first(char **array, int len) {
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement