Skip to content

Instantly share code, notes, and snippets.

@alsamitech
Last active April 22, 2021 06:24
Show Gist options
  • Select an option

  • Save alsamitech/ad20193e01f354ab0f8211f30b814753 to your computer and use it in GitHub Desktop.

Select an option

Save alsamitech/ad20193e01f354ab0f8211f30b814753 to your computer and use it in GitHub Desktop.
Requires: atokl aka compound_tokenizer, <stdio.h>, <stdlib.h>, <string.h>, and <ctype.h>
typedef struct _arr{
char* arr;
size_t len;
}arr_t;
arr_t lines_from_file(char* filenm){
arr_t filedata;
filedata.arr=read_file(filenm, &filedata.len);
if(!filedata.arr){
arr_t a={0, 0};
return a;
}
arr_t arr;
arr.arr=(char*)atokl(filedata.arr, "\n", &arr.len);
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment