free
This commit is contained in:
parent
b286c33f68
commit
1da31a52c9
@ -7,7 +7,7 @@
|
||||
|
||||
const int max = 1000;
|
||||
|
||||
void cut(char **argv, char *command){
|
||||
int cut(char **argv, char *command){
|
||||
int i = 0, w = 0, x = 0;
|
||||
char argument[100];
|
||||
while (1){
|
||||
@ -32,11 +32,12 @@ void cut(char **argv, char *command){
|
||||
w+=1;
|
||||
}
|
||||
}
|
||||
return w+1;
|
||||
}
|
||||
|
||||
int main (){
|
||||
char* argv[100];
|
||||
int i;
|
||||
int ile, i;
|
||||
while (1){
|
||||
char komenda[max], directory[max];
|
||||
if (getcwd(directory, sizeof(directory)) == NULL){
|
||||
@ -45,10 +46,8 @@ int main (){
|
||||
}
|
||||
printf("[%s]$ ", directory);
|
||||
fgets(komenda, max, stdin);
|
||||
cut(argv, komenda);
|
||||
for(i=0; i<5; i++)
|
||||
printf("%c ", argv[0][i]);
|
||||
printf("\n");
|
||||
ile = cut(argv, komenda);
|
||||
|
||||
if (argv[0]==NULL)
|
||||
continue;
|
||||
else if (strcmp(argv[0], "exit") == 0)
|
||||
@ -58,6 +57,9 @@ int main (){
|
||||
execvp(argv[0], argv);
|
||||
else
|
||||
wait(NULL);
|
||||
|
||||
for(i=0; i<ile; i++)
|
||||
free(argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user