107k views
3 votes
Design and implement a program to display each directory entry information (files and directories) of current directory, and with "chdir" call to change (current working directory) to its subdirectory.

1 Answer

6 votes

Answer: The code below can display directory as stated in the question

Step-by-step explanation:

char *

gnu_getcwd ()

{

size_t size = 100;

while (1)

{

char *buffer = (char *) xmalloc (size);

if (getcwd (buffer, size) == buffer)

return buffer;

free (buffer);

if (errno != ERANGE)

return 0;

size *= 2;

}

}

User Ian Harrigan
by
4.8k points