473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Can any help me to write program using Fork in C to generate this tree structure?

the tree in the the attachment below

this is my code that I'm tried to write :

Expand|Select|Wrap|Line Numbers
  1. #include<sys/types.h>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<unistd.h>
  5.  
  6. int main()
  7. {
  8.  
  9. printf("the parent id %d" , getpid());
  10.  
  11. pid_t pid1,pid2,pid3;
  12.  
  13. for (j=0;j<3;j++)
  14. {
  15. pid1=fork();
  16. printf("%d",getpid());
  17. }
  18. if (pid1==0)
  19. {
  20.  pid2=fork();
  21. elseif (pid3=fork();
  22. }
  23.  if((pid2 == 0)&&(pid3 == 0)) 
  24.    {
  25.        if (pid1 !=0)
  26.        fork();
  27.    }
  28.  
  29. printf("the process id %d" , getpid());
  30.  
  31. return 0;
  32.  
  33. }
  34.  
Attached Images
File Type: jpg 12745814_806546132825460_2140659547443282482_n (2).jpg (24.9 KB, 666 views)
Feb 21 '16 #1
1 1501
weaknessforcats
9,208 Expert Mod 8TB
This is too big a subject for a thread like this.

Start here:

https://www.youtube.com/watch?v=HDMkuDVuDyc
Feb 21 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Steve Johnson | last post by:
Been banging my head on this for two days now. Hope someone can help! My test program below is in the form of a single JSP, with a Node class build in. (All the coded needed to run is below.) ...
4
by: plork | last post by:
I'm trying to code a tree structure using javascript, the nodes of the tree are generated from a sql table. Has anyone some code for this? Cheers
1
by: Srihari | last post by:
I'm trying to develop a tree structure using javascript. The node values of the tree are generating from a mysql table depending on login. The tree structure contains 3 sub levels. I developed...
1
by: glenn | last post by:
Hi Folks, I would like to take a XML document and write its data into a tree structure for a custom tree control. The document has two fields with one called task (a text field) and the other...
0
by: abhishekjethwani | last post by:
How to write a query to access tree structure form multi table. I m having five tables from them first table give me a data which act as the parameter for query for the second table and the two...
5
by: chaching | last post by:
Please help. The code below will compile and run using the Dev C compiler, but not the Visual C++ 2005 express edition. I need it to run in the express editions. any suggestions? #include...
1
by: hmoundekar | last post by:
actually i want to generate a tree structure on client side, the application is simple web based, and need to display the data extracted from the database to client in tree structure. but the problem...
7
by: Woody714 | last post by:
I'm fairly new to C++ and have an assignment that is knocking me out. The text file is fairly simple: Plain Egg 1.45 Bacon and Egg 2.45 Muffin 0.99..... etc....
3
by: mattyizzo | last post by:
Here is my code. Basically I'm trying to solve for CI and CF, where each use a bunch of constants and a variable or two which can have up to 10 values. I get the following error, however, at line...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.