if i want to remove all the files in my current working directory using UNIX , i have a script and one of thie lines of this script is rm -rf /*Â Â would this work ? please explain why or why not ?? this is in C
what is the type of the parameter argv to the main funtion in a C proggram ?
Solution
UNIX rm command
rm-remove directory that removes files and directories.
The parameters of rm command is as follows
rm -rf
where r refers to remove files and directories recursively if contains
nested directories.
f refers to forcibly delete the directories and file if not exists
without prompt user to choose the decision about the file or directory.
argv is a parameter name of the character string that takes an
array of string arguments from main method of c program.
------------------------------------------------------------------------------------------------------------------------
//Sample program that demonstrates the use of argv vector array
//test.c
#include<stdio.h>
#include<conio.h>
//main function
int main(int argc, char * argv)
{
//Assign the argc to count
int count=argc;
int index;
//argv[0] represents the name of the program, test.c
//prints the strings in argv
for(index=1;index<count;index++)
printf(\"%s \",argv[index]);
//pause program output on console.
system(\"pause\");
return 0;
}
Sample output:
C:\\test.c hello c world
output: hello c world
.