Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

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

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
User
User
Cargando en…3
×

Eche un vistazo a continuación

1 de 2 Anuncio

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

Descargar para leer sin conexión

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
.

Anuncio
Anuncio

Más Contenido Relacionado

Similares a if i want to remove all the files in my current working directory usin.docx (20)

Más de edwardk6 (20)

Anuncio

Más reciente (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

×