ある配列から別の配列に 10 個の整数をコピーすることを目的としたプログラムがあります。エラーなしでコンパイルされています。次のようになります。
/* Program to copy a string from one array to another array and print the second array */
#include<stdio.h>
#include<conio.h>
#define MAX 10
void main()
{
int s[MAX]; // Original array
int c[MAX]; // Array which contains the copied contents of s[MAX]
int i;
printf("Enter the string of 10 characters");
for(i=0;i<MAX;i++) // Storing elements in the original array
{
scanf("%d",s[i]);
}
for(i=0;i<MAX;i++)
{
printf("%d",s[i]);
}
printf("\n");
for(i=0;i<MAX;i++) /*Copying the elements from the original array into the duplicate array*/
{
c[i]=s[i];
}
for(i=0;i<MAX;i++) //Printing the duplicate array
{
printf("%d",c[i]);
}
}
元の配列を印刷することすらありません。プログラムの後半部分である複製配列は言うまでもありません。