[so] redirectari

cosminratiu at gmail.com cosminratiu at gmail.com
Fri Nov 2 23:13:27 EET 2007


Nu e bine sa amesteci cout cu printf. Au buffering separat si pot apare
artefacte nedorite daca le folosesti amestecat. Choose one and stick with it
:).

On 11/2/07, Maria Nadejde <mnadejde at yahoo.com> wrote:
>
> am o mica problema cu redirectarile cand fac close la
> descriptori de fisier folositi la redirectare.
>
> in main (inspirat din main-ul din DisplayStructure :D)
> am urmatoarele instructiuni:
>
> for(;;)
> {
> printf("> ");
> .....
> if ((line.length() == 0) && !cin.good())
>                 {
>                         cout<<cin.rdstate();
>                         printf("am terminat\n");
>                         fflush(stdout);
>                         return EXIT_SUCCESS;
>                 }
> .......
> }
> cand fac redirectari dar nu fac close() pt fd totul
> merge bine
> dar cand fac si close() in procesul parinte pt file
> descriptori, pe ecran afiseaza ce trebuia sa afiseze
> (de ex pt cat < in.txt continutul fisierului) apoi
> apar  pe ecran:
>
>
> >am terminat
> >
>
> adik executa printf("am terminat") desi eu nu am dat
> CTRL+C, dar nu face si return EXIT_SUCCESS; si
> programul merge in continuare si primeste comenzi
>
> de ce nu se intampla lucrul asta in ambele cazuri si
> ce as putea face sa nu se mai intample deloc:)?
>
> Multumesc,
> Maria Nadejde
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> so mailing list
> so at cursuri.cs.pub.ro
> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/so
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cursuri.cs.pub.ro/pipermail/so/attachments/20071102/058a68ed/attachment.htm


More information about the so mailing list