I have a program that is intended to copy 10 integers from one array to another.It is compiling without any error. It goes as follows:-
/* 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]);
}
}
Its not even printing the original array. Let alone the duplicate array, which is the second half of the program.
This
scanf("%d",s[i]);should readscanf("%d",&s[i]);