[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] lagersegmentfejl coredumped ??



"Jan Arentoft" <sslug@sslug> writes:

> Hejsa
> 
> Hvad betyder det når linuxboxen skriver ( lagersegmentfejl coredumped)
> 
> ---cut---
> char *jann
> ---cut--
> jann=getenv("QUERY_STRING");
> ---cut--
> if (jann[i]==1);
> ---cut--
> 
> fjerner jeg en af disse linier i mit program kommer fejlen ikke længere, men
> så virker programmet jo ej heller som jeg ønsker....
> 

Grunden til at det går godt hvis du fjerner en af de to linjer er:

1) 
hvis du fjerner "jann=getenv("QUERY_STRING");"
så peger char * jann på et sted på din stak, som du godt må tilgå, men
vis indhold ikke giver nogen mening.

2)
Hvis du fjerner "if (jann[i]==1);"
så derefererer du ikke pegeren og så går det selvfølgelig godt.

Og som de andre har svaret, så er det jo nok fordi dit kald til
getenv(3) returnerer NULL som det skal når den pågældende environment
variabel ikke er defineret.

-- 
Christian Hemmingsen
P.L.U.R.                                   "Druk for fred!"
"My freedom of speech implies your freedom to be offended."
--Unknown


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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