Function

#include <iostream>
using namespace std;
int min(int *array,int size)
{
int *p=new int[size];
int min;
for(int i=0;i<size;i++){
p[0]=min;
if(p[i]<min)min=p[i];
p[i]=array[i];
return p;
}
}
int main()
{
int n,i;
int *p;
cout<<"how many char: ";
cin>>n;
p=new int[n];
if(p==0);
else{

for(i=0;i<n;i++)
{
cout<<"Enter Numbers : ";
cin>>p[i];
}
for(i=0;i<n;i++)
cout<<p[i]<<",";
cout<<endl;
delete []p;
}
cout<<"min is : "<<min(p,n)<<endl;
system("pause");
return 0;
}
must be in function where i wrong?
i solved *p is unnucessary
int min(int *array,int size)
{
array=new int[size];
int min;
for(int i=0;i<size;i++){
array[0]=min;
if(array[i]<min)min=array[i];
}
return min;
Topic archived. No new replies allowed.