Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFCCCC
langc
#include <stddef.h>
 
void copy(size_t n, char src[n], char dest[n]) {
   size_t i;
 
   for (i = 0; src[i] && (i < n); ++i) {
     dest[i] = src[i];
   }
   dest[i] = '\0';
}

...

Code Block
bgColor#ccccff
langc
#include <stddef.h>
 
void copy(size_t n, char src[n], char dest[n]) {
   size_t i;
 
   for (i = 0; src[i] && (i < n - 1); ++i) {
     dest[i] = src[i];
   }
   dest[i] = '\0';
}

...