I want to print pointer value after get the address from function return processing but, when i try to print 1 by 1 the program is fine ... but when i try to use loop, something happen ..
heres my code :
int *fibo(int input){
int a=0,b=0,fib=1;
int arrfibo[input];
int *arrfib;
for(int i=0;i<input;i++){
a = b;
b = fib;
arrfibo[i] = fib;
fib = a + b;
}
arrfib = arrfibo;
cout << arrfib << endl;
return arrfib;
}
main(){
int inp;
cout << "Enter number of fibonancci = ";
cin >> inp;
int *arr;
arr = fibo(inp);
for(int i=0;i<inp;i++){
cout << *(arr + i) << " ";
} // something wrong here the result is (1 1 4462800 4663360 0)
}
thanks, :)