Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/17/05 14:45
Modified:
  01/17/05 14:46

Read: times


 
#85101 - re commented
Responding to: ???'s previous message
The following function copies a zero-terminated string pointed by *src into *dest
*/
void strcpy(char *dest, char *src)
{
    while (1)                 // infinite loop begins
    {
        *dest = *src;         // copy one character from *dest to *src
        if (*dest == '')    // if the copied character is zero    
            return;           // abort the loop and return

        ++dest;               // increment destination pointer
        ++src;                // increment source pointer
    }
}
Do you really like this?

Nope not most of it

I specifically asked for Comments and most of what you wrote is not comments on what you try to achieve (important) but explanations of what is going on (if the reader does not know, (s)he should not read in the first place).

copy one character from *dest to *src is not a comment, it an "explanation of compiler behaviour" just like the frequently seen PUSH ACC; save accumulator on stack is explaining an instruction, not its purpuse.

However the function header is mandatory, and in this case, say all that is needed, although I would have liked "standard C library function" added.

Erik




List of 36 messages in thread
TopicAuthorDate
simple serial programs examples            01/01/70 00:00      
   Hello, World            01/01/70 00:00      
      Well, yes but            01/01/70 00:00      
         very basic            01/01/70 00:00      
            My point            01/01/70 00:00      
               basic            01/01/70 00:00      
                  but...            01/01/70 00:00      
         Dear oh dear            01/01/70 00:00      
            Impossible!            01/01/70 00:00      
               Avoiding mistakes            01/01/70 00:00      
                  'C' - the sloppy programmers choice            01/01/70 00:00      
                     bloatware in Pascal, too!            01/01/70 00:00      
                        Go on then....            01/01/70 00:00      
                     Horrible C            01/01/70 00:00      
                        Horrible programmer            01/01/70 00:00      
                           If that's you...            01/01/70 00:00      
                     Author, not the language            01/01/70 00:00      
                        Caveat            01/01/70 00:00      
                        language wars            01/01/70 00:00      
                           Bloat or bugs            01/01/70 00:00      
                        singer, not the song            01/01/70 00:00      
                           verbosit/clarity            01/01/70 00:00      
                              Poor, deluded hackers...            01/01/70 00:00      
                              Commented! :-)            01/01/70 00:00      
                                 re commented            01/01/70 00:00      
                                    Comments good and evil            01/01/70 00:00      
                                    comments            01/01/70 00:00      
                                    A quote from some wise people            01/01/70 00:00      
                                       Good but...            01/01/70 00:00      
                                          why...            01/01/70 00:00      
                                             Very true            01/01/70 00:00      
                                                been there, done that            01/01/70 00:00      
                                    Correct comments :-)            01/01/70 00:00      
                                       fishing in Minnesota            01/01/70 00:00      
                                 Author, not the language            01/01/70 00:00      
                                    bounds checks, error testing, comments            01/01/70 00:00      

Back to Subject List