Newer
Older
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++;
n++;
}
else if(temp == ' '){
long t = atol(tmp);
tab[j] = t;
memset(tmp, 0, 1000);
j++;
x=0;
}
read(fd,&temp,sizeof(char));
}
return n-1;
if(argc!=3){
printf("Usage: ./tri <option> <input.txt>\n");
exit(1);
}
long tab[100];
int n = readToTab(tab, argv[2]);
printf("Base : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
triInsertion(tab, n);
printf("Insertion : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
triFusion(tab, n);
printf("Fusion : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
triRapide(tab, n);
printf("Rapide : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");