Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

bonjour les amis

1 réponse
Avatar
Jean Pierre Daviau
Bonjour les amis,
Hé oui, c'est les vacances et qui est-ce qui se ramène?
Je tente d'améliorer TEE (je vous entends rire (ou râler))

Il fonctionne presque bien mais ce genre de stdin semble causer
une loop
dir *.txt | tee err


-----------------------------
#include <stdio.h>
#include <string.h>

int EXIT_FAILURE =1;
/* Note: [<tee.c] n'est pas considéré comme un argument */

int main(int argc, char *argv[])
{
FILE *outfile;
int ch;
int ecran;

if (argc < 2)
{
fprintf(stderr, "usage: tee [ <tee.c ] [ err ]with stderr [
tee.txt ]\n");
fprintf(stderr, " tee [ <tee.c ] [ err ]with stderr\n");
fprintf(stderr, " tee [ <tee.c ] [ tee.txt ]\n");
fprintf(stderr, " dir | tee [ err ] with stderr [
tee.txt ] \n");
fprintf(stderr, " dir will echo to stderr anyway\n");
return EXIT_FAILURE;
}

if(strcmp(argv[1],"err") != 0)
{
outfile = fopen(argv[1],"w+");
ecran = 1;
}else{
ecran = 0;
}

if(argv[2] != NULL){
outfile = fopen(argv[2],"w+");
}

while(!feof(stdin)) {
ch=fgetc(stdin);
if(!feof(stdin))
{
if(ecran == 0)
fputc(ch, stderr);
if(outfile!=NULL)
fputc(ch,outfile);
}
}

if(outfile!=NULL) fclose(outfile);

return 0;
}

-----------------------

Amicalement

Jean Pierre Daviau
--
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
Processor Radeon7000 0x5159 agp

1 réponse

Avatar
Jean Pierre Daviau
c'est réglé


for(i = 0;i<argc;i++){
if(strcmp(argv[i], "-out") == 0){
screen = 1;
}
}