FUNCTION

please help me, how to create function that will return array charecter....
why you don't use pointer.
can u give example.
ok, but does your array are created in your function?
yes array are created in function and i like to pass to variable...
Hi ,
Hope the code below may give u some idea.

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
#include<iostream>
using namespace std;

int* changeArray()
{
	int* b = new int[5];

	for(int i = 0; i<5;i++)
		b[i]=i+5;

	return b;
}

int main()
{
	int* x=0;

	x=changeArray();

	for(int i = 0; i<5;i++)
		cout<<x[i]<<endl;
	
	delete[] x;

	return 0;
}
Topic archived. No new replies allowed.