#include "utils.h"

int readToTab(long* tab, char* file){
    int n = 0;
    int fd = open(file, O_RDONLY);
    if(fd == -1){
        perror("open");
        exit(1);
    }
    char tmp[1000];
    memset(tmp, 0, 1000);
    char temp;
    size_t j = 0, x=0;
    read(fd,&temp,sizeof(char));

    while(temp != '.'){
        if(temp != ' '){
            tmp[x] = temp;
            x++;
            
        }
        else if(temp == ' '){
            long t = atol(tmp);
            tab[j] = t;
            memset(tmp, 0, 1000);
            j++;
            x=0;
            n++;
        }
        read(fd,&temp,sizeof(char));
    }
    return n-1;
}