| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 
 | /* j'utilise du C++ */
#include <stdio.h>
#include <boost/thread.hpp>
 
extern void fonction(FILE*);
 
/* normalement déclarée dans stdio.h mais absente*/
extern FILE* fmemopen(void*, size_t, const char*);
 
int main(int argc, char** argv)
{
    char* buf = malloc(512);
    FILE* iobuf = fmemopen(buf, 512, "w");
    FILE* iobuf2= fmemopen(buf, 512, "r");
    int index = 0;
 
    /* lancement du thread (C++) */
    boost::thread t (boost::bind(&fonction, iobuf2));
 
    for(index = 1; index < argc; ++index)
    {
        fprintf(iobuf, "%s", argv[index]);
        fflush(iobuf);
    }
 
    /* signal d'arret */
    fprintf(iobuf, "stop !!!");
 
    /* attente de la fin du thread (C++) */
    t.join();
 
    fclose(iobuf);
    fclose(iobuf2);
 
    return EXIT_SUCCESS;
} | 
Partager