106,819 views
3 votes
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.

User Todd W Crone
by
3.5k points

1 Answer

6 votes
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
2.8k points