ultio
01-05-2003, 17:17
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
int main(int arc, char *agrv[]){
int sorgente, destinazione;
char buffer[1024];
int leggi_byte;
sorgente = open("ciao.mp3", O_BINARY);
destinazione = open("brutto.mp3", O_BINARY | O_TRUNC | O_CREAT, S_IWRITE);
while(!eof(sorgente)){
if(leggi_byte = read(sorgente, buffer, sizeof(buffer)) <= 0){
fprintf(stderr,"1");
return 0;;
}
else if(write(destinazione, buffer, leggi_byte) != leggi_byte){
fprintf(stderr,"2");
return 0;
}
}
close(sorgente);
close(destinazione);
return 0;
}
se lo faccio partire crea il file di destinazione ma lo lascia vuoto....
perchč???? :-(
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
int main(int arc, char *agrv[]){
int sorgente, destinazione;
char buffer[1024];
int leggi_byte;
sorgente = open("ciao.mp3", O_BINARY);
destinazione = open("brutto.mp3", O_BINARY | O_TRUNC | O_CREAT, S_IWRITE);
while(!eof(sorgente)){
if(leggi_byte = read(sorgente, buffer, sizeof(buffer)) <= 0){
fprintf(stderr,"1");
return 0;;
}
else if(write(destinazione, buffer, leggi_byte) != leggi_byte){
fprintf(stderr,"2");
return 0;
}
}
close(sorgente);
close(destinazione);
return 0;
}
se lo faccio partire crea il file di destinazione ma lo lascia vuoto....
perchč???? :-(