Fibonacci in C works great with 1 - 18 but 19 does nothing at all...
Posted
by shevron
on Stack Overflow
See other posts from Stack Overflow
or by shevron
Published on 2010-05-21T07:35:50Z
Indexed on
2010/05/21
7:40 UTC
Read the original article
Hit count: 234
Yeah right... we are forced to programm some good old C at our university... ;) So here's my problem:
We got the assignment to program a little program that show a fibonacci sequence from 1 to n 1 to 18 works great. But from 19 the program does nothing at all and just exit as it's done. I can not find the error... so please give me a hint. :)
#include
#include
#include
#include
int main(int argc, char **argv)
{
pid_t pid;
int fib[argc];
int i, size;
size = strtol(argv[1], NULL, 0L);
fib[0] = 0;
fib[1] = 1;
pid = fork();
printf("size = %d \n", size);
if(pid == 0){
for(i = 2; i 0){ // Parent, because pid > 0
wait(NULL);
printf("\n");
exit(1);
}
}
Thanks already!
© Stack Overflow or respective owner