Aug 21, 2012 at 8:43am Aug 21, 2012 at 8:43am UTC
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int *temp;
temp=new int[10];
int get(int *temp);
void display(int *temp);
getch();
}
int get(int temp[])
{
for(int i=0;i<10;i++)
{
cin>>temp[i];
}
return *temp;
}
void display(int temp[])
{
for(int i=0;i<10;i++)
{
cout<<temp[i];
}
}
Aug 21, 2012 at 8:48am Aug 21, 2012 at 8:48am UTC
Please, re-post your code with code tags, (you can find it under "Format:" ), and specify your problem.
Aug 21, 2012 at 8:51am Aug 21, 2012 at 8:51am UTC
it is not get values by cin
Last edited on Aug 21, 2012 at 8:52am Aug 21, 2012 at 8:52am UTC
Aug 21, 2012 at 9:21am Aug 21, 2012 at 9:21am UTC
can u tell me what is wrong with it.. i want to knw how to pass array pointer to function
Aug 21, 2012 at 9:28am Aug 21, 2012 at 9:28am UTC
Pass the pointer to the function. You need to declare the function to take a pointer parameter.
Last edited on Aug 21, 2012 at 9:29am Aug 21, 2012 at 9:29am UTC
Aug 21, 2012 at 9:40am Aug 21, 2012 at 9:40am UTC
how can u write a right code
Aug 21, 2012 at 10:10am Aug 21, 2012 at 10:10am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#include<iostream>
#include<conio.h>
using namespace std;
void get( int *temp, int n );
void display( const int *temp, int n );
int main()
{
const int N = 10;
int *temp;
temp = new int [N];
get( temp, N );
display( temp, N );
getch();
return ( 0 );
}
void get( int temp[], int n )
{
for ( int i = 0; i < n; i++ ) cin >> temp[i];
}
void display( const int temp[], int n )
{
for ( int i = 0; i < n; i++ ) cout << temp[i];
}
Last edited on Aug 21, 2012 at 10:16am Aug 21, 2012 at 10:16am UTC