Note that there are some explanatory texts on larger screens.

plurals
  1. POFork() and parent/child processes
    primarykey
    data
    text
    <p>This is the question on my homework and what the teacher expects as output...I am confused as to where to go from here I have included my code. My output is both the child process and parent process in the thousands</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;unistd.h&gt; main() { /* Create three variables */ /* One to create a fork */ /* One to store a value */ /* One to use as a count control for a loop */ /* Initialize value variable here */ ; printf("Ready to fork...\n"); /* Create fork here */ if ( /* Condition to determine if parent */ ) { printf( "The child executes this code.\n" ); for ( /* Count control variable set to zero, less than five, incremented */ ) /* Value variable */ = /* What does value variable equal? */ ; printf( "Child = /* The ending value variable goes here */ " ); } else { for ( /* Count control variable set to zero, less than five, incremented */ ) /* Value variable */ = /* What does value variable equal? */ ; printf("Parent = /* The ending value variable goes here */ "); } } Here is the output from my program: Ready to fork... The parent executes this code. Parent = 3 The child executes this code. Child = 10 </code></pre> <p>This is what my code is</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;unistd.h&gt; main() { /* Create three variables */ int frk; int val; int count; val=0; printf("Ready to fork...\n"); frk=fork(); if ( frk==0 ) { printf( "The child executes this code.\n" ); for (count=0; count&lt;5; count++ ) val = frk ; printf( "Child = %d\n",val ); } else { for (count=0; count&lt;5; count++ ) val = frk; printf("Parent = %d\n ",val); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload