how to use fork function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • che wan
    New Member
    • Sep 2008
    • 2

    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.
    Code:
    #include<stdio.h>
    #include<math.h>
    
    int a[50][50];
    int b[50][50];
    int c[50][50];
    int i,j,m,n,p,q;
    
    void main()
    {
    
    //clrscr();
    printf("\n enter order of Anxn matrix: \n");
    scanf("%d%d",&n,&m);
    printf("\n enter order of Bnxn matrix: \n");
    scanf("%d%d",&p,&q);
    if(n!=p)
    	{
    		printf("\n additional is impossible \n");
    	}
    else
    	{  printf("\n enter elements of matrix Anxn: \n");
    		for(i=0;i<n;i++)
    			{
    				for(j=0;j<n;j++)
    				{
    					scanf("%d",&a[i][j]);
    				}
    			}
    		printf("\n enter elements of matrix Bnxn: \n");
          for(i=0;i<p;i++)
    			{
    				for(j=0;j<p;j++)
    					{
    						scanf(" %d",&b[i][j]);
    					}
          	}
    		printf("\n order of matrix C is %dx%d ",n,p);
    		for(i=0;i<n;i++)
    			{
                   for(j=0;j<p;j++)
    					{				
    					     c[i][j]=(a[i][j] + b[i][j]);
    					}
       		}
          printf("\n\n matrix C is : \n");
          for(i=0;i<n;i++)
    			{
    				for(j=0;j<p;j++)
    					{
    						printf(" %d\t",c[i][j]);
    					}
                printf("\n");
    			}
       }
    getch();
    }

    somebody plz help me!!!!
    i need to send it soon
  • whodgson
    Contributor
    • Jan 2007
    • 542

    #2
    main() must be of type 'int' ..........i think.

    Comment

    • Laharl
      Recognized Expert Contributor
      • Sep 2007
      • 849

      #3
      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).

      Comment

      Working...