Files 461
# include <process.h>
main (int argc, char *argv [])
FILS *fp;
i f (argc<2)
printf (" Insufficient Arguments");
if(fp = = N U L L)
printf ("File Not Found");
unlink (argvll]);
printf ("File fias been deleted ");
return 0;
Explanation This program performs task of DEL command of disk operating system. It deletes
only one file at a time. Create exe file of this program and execute it on the command prompt. User
should give the file name for deleting. Opening it in read mode checks the existence of file. The file will
be deleted in case it exists. In the program appropriate messages are displayed if the user makes any
mistake. Error messages are "Insufficient Arguments", "File not found" and "File has been deleted
3. Rename
13.4 Write a program using command line argument to perform the task of REN command of DOS.
(Save this program as change.c)
# include <8tdio.h>
# include cconio.h>
# include <proceas.h>
main( int argc, char * a r g v [])
FILS *£p,*spj
i f (argc<3 )
printf ("Insufficient Arguments");

Get Programming and Data Structures now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.