C Program that demonstrates redirection of standard output to a file

Gcc: The GNU compiler can be used for to compile the c programs.

Orphan process: The child process can not having the parent process

				
					#include<stdlib.h> 
#include<stdio.h>
#include<string.h> 
main(int argc, char *argv[]) 
{ 
char d[50]; 
if(argc==2) 
{ 
bzero(d,sizeof(d));
strcat(d,"ls "); 
strcat(d,"> "); 
strcat(d,argv[1]); 
system(d); 
}
else
printf("\nInvalid No. of inputs");
}

				
			

Leave a Reply