I pretty much got my assignment working except for one part, I need to reverse the output if the user enters "-r" in the command line. Can anyone help me with this?

EDIT: By reverse I mean list the last child first down to the original process.

int j = strcmp( argv[2] , "-r" );
if ( j == 0 ){
	 printf("if statement entered\n");
   	 for( c = 0; c < depth; c++ ){
	
		if((fork())== 0)
   	       printf( "Process %d reporting; parent is %d\n", getpid(), getppid() );
  	     else{
		   wait();
		   exit(0);
		}
  	  }		

    }