This commit is contained in:
Jakub Adamski 2019-01-10 12:00:32 +01:00
parent 8861a640e7
commit a891e88afe
3 changed files with 35 additions and 0 deletions

BIN
zajecia11/lab_ls Executable file

Binary file not shown.

33
zajecia11/lab_ls.c Normal file
View File

@ -0,0 +1,33 @@
#include <dirent.h>
#include <errno.h>
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char** argv)
{
DIR *dir;
struct dirent *entry;
char cwd[1000];
if (getcwd(cwd, sizeof(cwd)) == NULL)
perror("getcwd() error");
if (argc == 2)
strcpy(cwd, argv[1]);
if ((dir = opendir(cwd)) == NULL)
perror("blad opendir");
else
{
printf("Dir: %s\n", cwd);
while ((entry = readdir(dir)) != NULL)
printf(" %s\n", entry ->d_name);
closedir(dir);
}
return 0;
}

2
zajecia11/notatki.txt Normal file
View File

@ -0,0 +1,2 @@
jak sprawdzic ilosc elementow argv[1]!