[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] gets strengen



--- "Egon Andersen, Talura" <sslug@sslug> wrote:
> Sune wrote:
> > 
> [snip]
> 
> Anders har som bekendt ret!

LOL ;)

> Da du er meget interesseret i at lade compileren lave 'beviserne' for
> dig, istedet for at læse og forstå dokumentationen, så skal jeg gerne
> give dig et eksempel.
> 
> ~~~
> char a[300] = "abc-programmering";
> char * p;
> 
> int main()
>   {
>   p = a;
>   /* Nu kan 'p' bruges til det samme som 'a' ifølge Sune */
> 
>   /* Det ser da også sådan ud ... */
>   printf("p: %s, a: %s\n", p, a); 
> 
>   /* men nej ... */
>   printf("sizeof p = %zd, sizeof a = %zd\n", sizeof p, sizeof a);
> 
>   return 0;
>   }

Yes, fint eksemple, men det modbeviser jo ikke det jeg har sagt.
Det jeg siger er, at compileren opfatter og anvender a som en pointer til arrayet, 
hvis du spørger den hvad værdien er, så giver den dig en adresse til a[0], hvis du spørger om
længen, så siger den "aha, hvor lang er den array som a peger til", det er som du nok kan forstå
noget helt andet.

-S.

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/


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