Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,401 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,117 people online right now. Registration is fast and FREE... Join Now!




Fibonacci sequence utlizing the fork() function

 
Reply to this topicStart new topic

Fibonacci sequence utlizing the fork() function, C program using fork() to generate fibonacci seq. in child process. P

como
28 Sep, 2006 - 08:43 PM
Post #1

New D.I.C Head
*

Joined: 28 Sep, 2006
Posts: 1


My Contributions
CODE


#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

main(int argc, char *argv[6])
{       int fib[5];
        int i;
        int pid;
        fib[0] = 0;
        fib[1] = 1;

    pid = fork();
    if (pid < 0) {
        fprintf(stderr, "Error occurred\n");
        }
    else

    if (pid == 0) {
        for(i = 1; i < 6; i++)
                fib[i] = fib[i-1] + fib[i-2];

        for (i = 1; i < argc; i++)
                printf("%3d   %6d\n", argv[i], i < argc - 1 ? " " : "");
    wait (5);
           printf("Parent waiting for child\n");
    exit(1);
    }
    else
    return 0;
}

rolleyes.gif
User is offlineProfile CardPM
+Quote Post

MingusDew
RE: Fibonacci Sequence Utlizing The Fork() Function
28 Sep, 2006 - 11:56 PM
Post #2

New D.I.C Head
*

Joined: 28 Sep, 2006
Posts: 13


My Contributions
CODE

#include <unistd.h>


where might i find this .h file im on a windows system

This post has been edited by MingusDew: 29 Sep, 2006 - 01:05 AM
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Fibonacci Sequence Utlizing The Fork() Function
29 Sep, 2006 - 10:01 AM
Post #3

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,935



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
CODE

#include <unistd.h>
#include <sys/types.h>

I don't think that these header files can be used for Windows.
They're more likely to be for *NIX variants.

I might be wrong though, I'm not exactly sure.

But if you still want to get the header file, visit www.filesearching.com and search for the header file.
You get plenty of results.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 03:08AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month