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

前端 未结 7 1639
广开言路
广开言路 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 08:56

    The problem is exactly here:

    int i;
    for(i<0;i<=count;i++)
        std::cout<

    You are not assigning i any start value. Change it to:

    for (int i = 0; i < count; i++)
        std::cout << p[i] << std::endl;
    

提交回复
热议问题