Linux C Programs Get directory information (16)

Source: Internet
Author: User

4. Get the current directory
GETCWD will copy the current working directory absolute path to the memory space referred to by the parameter buf
5. Set up working directory
ChDir
6. Get directory information
Opendir Open a Directory
Readdir Reads directory entry information from the contents of a directory, returns a struct dirent struct pointer
Closedir Close an Open Directory


Implementing the LS command-l-a
Implementation process:
1. Get the total number of files and the longest file name in this directory
2. Get all the file names in this directory and store them in filenames
3. Use the bubbling method to sort the files alphabetically, sorted and stored in filename
4. Call display (Intflag,char *filename) to show each file information

Code to be implemented ...

Linux C Programs Get directory information (16)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.