[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] pointer gymnastik



Kim Pedersen <sslug@sslug> skrev:

> >  for (p = str, i = 0; *p != '\0'; *p++, i++)
> 
>   assignmenten: *p++ virker kun på grund af at hvad du har puttet ind i den
> pointer to char incrementerer liniært, men vil ikke virke på alle
> compilers, at sige p++ derimod vil incrementere p til den næste hukummelses

Hvad?

En streng incrementerer lineært? *p++ har anden sideeffekt på p end
p++ har?

Da resultatet af udtrykket ikke bruges, kan det vel være et fedt, om
man bruger pointeren, eller det, den peger på?

Eneste regel, jeg kan komme i tanke om er, at man ikke må de-reference 
en pointer, der peger på uallokeret hukommelse, men da løkken afbrydes 
når *p == 0 bliver det næppe et problem.

-- 
Regards, Anders                         If a Microsoft product
(address is valid)                      fails, who do you sue?


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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