[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: [CPROG] Returnerin af at "string" array



Carsten Svaneborg <sslug@sslug> skrev:

> void ParseLog(char *filename)
> 
> ENDLines er globalt defineret. Og du behøver derfor ikke at
> returnere den fra din funktion.

En mere ren tilgang til dette aspekt havde nok været "ENDLines
returneres fra din funktion og du behøver derfor ikke at lave den
global".


> 200 bør være 199 fordi du skal have plads til det 0 der viser
> hvornår strengen slutter.

Som Mads sagde.


>   if (i>=N) 
>     {
>       N+=100;
>       Endlines=(char**)realloc(Endlines, N*sizeof(char*) ); 

[...]

> // Check altid for om malloc operationen virker, dvs. om der er ram
> // nok, ellers vil programmet crashe på et eller andet tidspunkt.

Dette gælder også for realloc() ;-).


>   if (EndLines[i]==NULL)
>      { printf("Out of memory!"); exit(42); }

EXIT_FAILURE er nok et bedre valg end 42.

-- 
Regards, Anders


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 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] *