Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List * readFileToList() {
- List * list = List_new();
- char * buffer = malloc(sizeof(char)*100) ;
- char * stringBuffer = malloc(sizeof(char)*100) ;
- const char * input = readFileToBuffer("data.txt", buffer, 10000);
- while(input != '\0'){
- if (isdigit(*input))
- {
- while (isdigit(*input))
- {
- StringBuffer_appendChar(stringBuffer, *input);
- input++;
- }
- int* i = malloc(sizeof(int));
- char * buf = StringBuffer_toNewString(stringBuffer);
- *i = atoi(buf);
- free(buf);
- List_add(list, i);
- StringBuffer_clear(stringBuffer);
- }
- input++;
- }
- return list;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement