How to return an array from a function and loop through it?

前端 未结 7 1628
广开言路
广开言路 2021-01-24 08:12
#include 

int* fib(int);

int main()
{
    int count;
    std::cout<<\"enter number up to which fibonacci series is to be printed\"<

        
相关标签:
7条回答
  • 2021-01-24 09:04

    One problem is that you allocate the array one element too short. The parameter in new[] is the number of elements, not the highest index.

    Another problem is that you allocate the array in two places, but that only creates a memory leak and doesn't affect the result.

    0 讨论(0)
提交回复
热议问题