Declaration of function

Hello!
Is that the normal function declaration, for function named "numbers" having 2 parameters (int a - reference and int st-by value?)



int * numbers(int * a, int st) {

MANY THANKS!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int * numbers(int * a, int st) {
int number, result;
int nindex = 0;
for(int i=1; i<st; i++) {
number = i;
result = Prime(number);
if( result == 1) {
a[nindex] = number;
nindex++;
}
if(nindex>5) return a;
}
return a;
}
First of all please use indentation...

http://indentcode.net/


Secondly you are not using references you are using pointers.

Also can you specify normal please?

It is normal if you want to return a pointer , pass a pointer, pass copy.
If you are trying to return a copy , pass a reference, pass a copy then no it would look like
1
2
3
4
5
int numbers( int &a , int st )
{
    //stuff
    return( some_value );
}

Topic archived. No new replies allowed.