Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,859 questions

51,780 answers

573 users

How to copy all elements of one dimensional int array into another array in C

1 Answer

0 votes
#include <stdio.h>

#define LEN 7

int main(void)
{
	int arr1[] = { 2, 234, 1, 800, 100, 9, 12237 };
	int arr2[LEN];
	int i;
	
	for (i = 0; i < LEN; i++) 
		arr2[i] = arr1[i];
 
	for (i = 0; i < LEN; i++) 
		printf("arr2[%d] = %d\n", i, arr2[i]);

    return 0;
}
  
    
/*
      
run:

arr2[0] = 2
arr2[1] = 234
arr2[2] = 1
arr2[3] = 800
arr2[4] = 100
arr2[5] = 9
arr2[6] = 12237

*/

 



answered Feb 2, 2016 by avibootz

Related questions

1 answer 142 views
3 answers 252 views
1 answer 184 views
1 answer 157 views
1 answer 134 views
1 answer 153 views
...