In this section, you will learn how to copy an array in C.
The example below contains two arrays: array1 and array2 with sizes 5 respectively. Here the size of an array states its capacity to hold maximum number of values.
Now in the example each element of array1 is assigned
a value. Then, in order to copy the elements of array1 into array2, we have
used for loop with which the values located at the indexes of array1
will be as it is get copied and pasted at the same indexes of array2.
Here is the code:
ARRAYCOP.C
#include <stdio.h>
|
The array is copied consisting of same elements:
ARRAYCOP.EXE

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: C Array copy example View All Comments
Post your Comment