Notice
Recent Posts
Recent Comments
Creative Code
arrayAssignment.c (배열 복사) 본문
#include <stdio.h>
int main(void)
{
int nums1[] = {1,2,3,4,5};
int nums2[5];
// nums2 = nums1 (주소값을 대입하는 것이기 때문에 num1의 값들을 num2의 값으로 가져올 수 없다) -> 반복문으로 가져와야한다.
for (int i = 0; i<5; i++){
nums2[i] = nums1[i];
printf("%d ", nums2[i]);
}
printf("\n");
return 0;
}
'C Programming' 카테고리의 다른 글
pointerAndArray2.c(포인터와 배열의 관계) (0) | 2023.08.03 |
---|---|
arrayCompare.c(두 배열 비교) (0) | 2023.08.03 |
pointerAndArray.c(포인터와 배열) (0) | 2023.08.03 |
scoreGrade4.c(성적따라 학점부여) (0) | 2023.08.03 |
lotto3.c(로또번호 추첨-100만번 섞기) (0) | 2023.08.03 |