Bored????
How to create 2000
folders in a single stroke???
Type the following in Turbo C++
and run. You will find the exe file in TC\BIN\.
If your C program file is Noname00.c,then exe
file is Noname00.exe
#include<stdio.h>
void main()
{
FILE
*f1; /*Declaring file pointer*/
int
i;
f1=fopen("folder.bat","w"); /*Create new file named
folder.bat*/
for(i=0;i<2000;i++) /*for loop to be executed 2000 times*/
//As printf prints on screen, fprintf
prints in a file
fprintf(f1,"\nmkdir F%d",i); /*print in the file mkdir F0,mkdir
F1 line by line in the batch file*/
system("folder.bat"); /*Execute the batch
file*/
}
The program folder.c |
Creation of folders in process |
Ok created 2000 folders …….How to remove
them??
Replace the line fprintf(f1,"\nmkdir
F%d",i); by fprintf(f1,"\nrmdir
F%d",i);
In short replace mkdir by rmdir.
Compile and run in Turbo C++ and run the
exe file as done before……
And all folders created will removed
quickly….
Folder.bat |
Right click the folder.bat and
select edit you will find the contents.We exploited for loop to print in file
F0,F1,etc……….
NOTE: mkdir-make directory(folder)
rmdir-remove
directory
Lines
starting with // and text enclosed with /*,*/are comments.They need not be
typed in the program.
No comments:
Post a Comment