Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

if i want to remove all the files in my current working directory usin.docx

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Nächste SlideShare
User
User
Wird geladen in …3
×

Hier ansehen

1 von 2 Anzeige

if i want to remove all the files in my current working directory usin.docx

Herunterladen, um offline zu lesen

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
.

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
.

Anzeige
Anzeige

Weitere Verwandte Inhalte

Ähnlich wie if i want to remove all the files in my current working directory usin.docx (20)

Weitere von edwardk6 (20)

Anzeige

Aktuellste (20)

if i want to remove all the files in my current working directory usin.docx

  1. 1. 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
  2. 2. 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

×