• [^] # Re: ta solution ?

    Posté par . En réponse au message programme c qui émule la commande cat (solution trouvée hipipip houraaaaaaaaaaaa). Évalué à 1.

    voila:
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <stdio.h>

    int main (int argc, char*argv[])
    {
    int i;
    int byte_lu;
    int d;
    char tampon [1024];
    ssize_t fd;
    for (i=1; i<argc; i++)
    {
    d= open(argv[i],O_RDONLY);
    if(d==-1)
    {
    printf("these file does not exist check the name\n");
    return(2);
    }

    Else{
    While((byte_lu=read(d,tampon,1024)) >0){
    fd= write(STDOUT_FILENO,tampon,byte_lu);
    close(d);

    }
    }


    Return(0) ;


    }