[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] Extern funktion



Selv hej

Den er nem. Funktionen func_check modtager parameteren dynamisk via
stakken og returnerer ikke en ny værdi. Derfor får func_check ingen
indflydelse på værdien. Du kan enten vælge at lade funktionen returnere
en værdi, eller du kan operere på en pointer til variablen.

Jeg retter lige i din originale tekst nedenunder:

Peter Gylling wrote:
> 
> Hej,
> 
> Jeg sidder lige og undrer mig over nedenstående.
> 
> Fra hoved-filen defineres en ekstern funktion.
> --SNIP--
> /* Definition af en ektern rutine fra filen check.c */
> extern func_check(int *tjek);       <----- rettet
> 
> main()
> {
>   int tjek;
> 
>   tjek = 5;
>   func_check(&tjek); <----- rettet
> 
>   printf("tjek = %d\n",tjek);
> 
>   return(0);
> }
> --SNIP--
> Den ekterne funtion er som følger:
> --SNIP--
> /* Kaldes fra main.c */
> func_check(int *tjek) <----- rettet
> {
> 
>   ++(*tjek); <----- rettet
> }
> --SNIP--
> Når dette kompileres med gcc fås output af tjek til tjek=5, men
> hvorfor det?
> 
> vh Peter Gylling

Som du ser ganske lidt rettelse og nu vil den gøre det du sikkert
forventer

M.v.h.
Søren H. Sørensen
-- 
Man ser en gammel, træt traktor slæbe sig langsomt over en gårdsplads.
Den kører helt fast da den kører ind i et skur og står stille med
hjulene spinnende rundt. Det er en reklame for Windows-2000, mon den
skal tages beskrivende?????


 
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] *