Fibonacci generator

Hello,Im a newbie and i need some help,i want to generate fibonacci numbers until n and put it in an array but the code i wrote gives me only 0's.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 void fibonacci(int n,int t[100])
{
    int first=1,second=1,next=0;
    t[0]=first;
    t[1]=second;
    for(int i=2;i<=n;i++)
    {
        next=first+second;
        t[i]=next;
        first=second;
        second=next;
    }
}
//----------------------------------------- 
How do you call your function?
I already solved it ^^ ,the problem was elsewhere.When i tried to put in the numbers in a matrix i wrote something verso and it ruined the whole thing.The function is working properly :D
and i called it like this:

 
 fibonacci(n,t);
Topic archived. No new replies allowed.