473,320 Members | 2,145 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,320 software developers and data experts.

how to use fork function

hi...i'm a new in C language.it is my sample program but i don't know to include the fork function.
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int a[50][50];
  5. int b[50][50];
  6. int c[50][50];
  7. int i,j,m,n,p,q;
  8.  
  9. void main()
  10. {
  11.  
  12. //clrscr();
  13. printf("\n enter order of Anxn matrix: \n");
  14. scanf("%d%d",&n,&m);
  15. printf("\n enter order of Bnxn matrix: \n");
  16. scanf("%d%d",&p,&q);
  17. if(n!=p)
  18.     {
  19.         printf("\n additional is impossible \n");
  20.     }
  21. else
  22.     {  printf("\n enter elements of matrix Anxn: \n");
  23.         for(i=0;i<n;i++)
  24.             {
  25.                 for(j=0;j<n;j++)
  26.                 {
  27.                     scanf("%d",&a[i][j]);
  28.                 }
  29.             }
  30.         printf("\n enter elements of matrix Bnxn: \n");
  31.       for(i=0;i<p;i++)
  32.             {
  33.                 for(j=0;j<p;j++)
  34.                     {
  35.                         scanf(" %d",&b[i][j]);
  36.                     }
  37.           }
  38.         printf("\n order of matrix C is %dx%d ",n,p);
  39.         for(i=0;i<n;i++)
  40.             {
  41.                for(j=0;j<p;j++)
  42.                     {                
  43.                          c[i][j]=(a[i][j] + b[i][j]);
  44.                     }
  45.            }
  46.       printf("\n\n matrix C is : \n");
  47.       for(i=0;i<n;i++)
  48.             {
  49.                 for(j=0;j<p;j++)
  50.                     {
  51.                         printf(" %d\t",c[i][j]);
  52.                     }
  53.             printf("\n");
  54.             }
  55.    }
  56. getch();
  57. }

somebody plz help me!!!!
i need to send it soon
Sep 19 '08 #1
2 1577
whodgson
542 512MB
main() must be of type 'int' ..........i think.
Sep 20 '08 #2
Laharl
849 Expert 512MB
You're correct. For fork(), #include <unistd.h>. Keep in mind that if you're working on windows, that file does not exist as it is the unix standard header (linux has it too).
Sep 20 '08 #3

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

Similar topics

7
by: C Gillespie | last post by:
Dear All, I have a function def printHello(): fp = open('file','w') fp.write('hello') fp.close() I would like to call that function using spawn or fork. My questions are:
2
by: CwK | last post by:
How to use fork() system function to fork multi child process at the same time ? For example: Run a program to fork 5 child process at the same time and the parent must wait until all child...
1
by: Gvs | last post by:
Hi, I'm just playing around with forking processes and was wondering how can you keep a child alive as long as the parent is alive. To give an example here is my code. ...
11
by: ramu | last post by:
Hi All, We know that a c function never returns more than one value. Then how come the fork() function returns two values? How it is implemented? Regards
1
by: vduber6er | last post by:
Hi I want to have a wait page while the rest of the cgi does its process, but it seems like the wait page waits till everything is complete and never appears. I've tried forking twice already as...
5
by: JoeW | last post by:
Now before I go into detail I just want to say that this is purely for my own benefit and has no real world usage. I remember way back when the tool for *nix systems called forkbomb was created. I...
1
by: ohaqqi | last post by:
Hi guys, I'm still working on my shell. I'm trying to implement a function typefile that will take a command line input as follows: > type <file1> This command will implement a catenation of...
4
by: rohitsagar | last post by:
I want to do fork from a program Code is very simple, below is the code, it just execute a executable called a.exe, I want to run a.exe 600 times. #include<stdio.h> #include<stdlib.h> void...
4
by: AK | last post by:
Hi everyone, Please check out this query that I have in : http://groups.google.com/group/progav/browse_thread/thread/29057ec587dd46b3 (its a bit long, thats why I am not typing it again;...
1
by: 3srt | last post by:
Hello, I created a simple 'server' script that will accept input from a cgi script. The server will handle multiple connections on the same port, also. In a nut shell, this 'server' script will...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.