#include <iostream>
#include <cmath>
using namespace std;
void input(int(&x)[10]);
int copy(int (&x)[10], int(&y)[10]);
void read(int(&x)[10], int b);
int main()
{
int m[10], v[10], c;
input((&m)[10]);
read((&m)[10], 10);
c = copy((&m)[10], (&v)[10]);
read((&v)[c],c);
system("PAUSE");
return 0;
}
void input(int(&x)[10])
{
for(int i=0; i < 10; i++)
{
cout<<"enter number "<<i+1<<": ";
cin>>x[i];
}
}
void read(int(&x)[10], int b)
{
for(int i=0; i < b; i++)
{
cout<<"number("<<i+1<<"): "<<x[i];
}
}
int copy(int(&x)[10], int(&y)[10])
{
int c = 0;
for(int i = 0; i < 10; i++)
{
if(x[i] % 3 == 0)
{
y[c]=x[i];
c++;
}
}
return c;
}
I get a runtime error when i input the first number, any help will be appreciated I think the problem is in the way i pass the arrays to the functions but I am not really sure the aim of the program is to get input for 10 int-s in the array m, than transfer those divisible by 3 to v, and output both