title: Make a C program to copy char array elements from one array to another and don´t have to worry about null character
body: <p>I want to create a program that copies, element by element, one char array to another but the problem is that, if I don´t introduce in the destination array the null character, the program outputs the correct String + weird characters, so my solution was to iterate through with the length of the String + 1 in order to include the null character, is there any way to iterate with the length of the String without having to worry about the null character? The code is as follows:</p>
  
  <pre><code>int copy(char * source, char * destination, unsigned int lengthDestination);
  
  int copy(char * source, char * destination, unsigned int lengthDestination) 
  {
      int i;
      for(i = 0; source[i] != '\0'; i++) {
          //Count the length of the source array
      }
      if(i + 1 != lengthDestination){ //i + 1 in order to take into account '\0'
         return 1;
      }
  
      for(int j = 0; j &lt; lengthDestination; j++) {
          destination[j] = source[j];
      }
      return 0;
  }
  
  int main() {
      char * source = "Test number 17"; //Length is 15 counting the null character
      unsigned int destinationLength = 15;
      char destination[destinationLength];
      copy(source, destination, destinationLength);
      printf("The String source is: %s\n", source);
      printf("The String destination is: %s\n", destination);
      return 0;
  }
  </code></pre>