[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

RE: [PROGRAMMERING] C rutine til exec + pipe til og fra



> En måde at undgå alle disse goto'er er at åbne og lukke filerne i en
> funktion og køre funktionaliteten i en anden.
> 
> concept code:
> 
> int funktionalitet(FILE *fil) {
>   /* gør noget med fil og returner ved fejl */
> }
> 
> int openclose() {
>   FILE
>     *fil = fopen(...);
> 
>   if (fil)
>     funktionalitet(fil);
>   else
>     ;/* fejl melding */
>   
>   fclose(fil);
> }

Dette bliver straks en del mere kompliceret med flere fejlkilder, som i
vores tilfælde. Men det kunne da være interessant at se en fuld version
med denne teknik og sammenligne. Jeg er stadigvæk af den overbevisning,
at versionen med gotos er nemmest at forstå.

> i C++ er det noget lettere
Helt enig. I C++ kan man - i vores tilfælde - fuldstændig undgå
gotos OG få mere læsbart kode.

Nu er det dog en C routine der blev efterspurgt.



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *