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);
		}
  	  }		

    }

Please disregard. I have solved this issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.