zajecia
This commit is contained in:
parent
8861a640e7
commit
a891e88afe
BIN
zajecia11/lab_ls
Executable file
BIN
zajecia11/lab_ls
Executable file
Binary file not shown.
33
zajecia11/lab_ls.c
Normal file
33
zajecia11/lab_ls.c
Normal 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
2
zajecia11/notatki.txt
Normal file
@ -0,0 +1,2 @@
|
||||
jak sprawdzic ilosc elementow argv[1]!
|
||||
|
Loading…
Reference in New Issue
Block a user