Unix/linux Programming Practice Tutorial (0:)

Source: Internet
Author: User

Originally intended to read the socket and other related content, but the writing is really good, or decided to read the rest of the content.

An example of reading online Help:

Open System Call:

Read system call:

Time for Unix:

printf above can be seen, a temporary char* pointer can also be +4, want to see if there is malloc in the CTime function, if any, who will release the memory??? If not, why can the pointer operate.

To solve the above doubts, by looking at http://www.cplusplus.com/reference/ctime/ctime/and http://www.cplusplus.com/reference/ctime/asctime/, get:

CTimeChar* CTime (Consttime_t *timer); Convert time_t value tostringThis function isequivalent To:asctime (localtime (timer))asctime Char* Asctime (Const structTM *timeptr); CONVERT TM Structure tostringIt isdefined with a behavior equivalent to:Char* Asctime (Const structTM *timeptr) {  Static Const Charwday_name[][4] = {    "Sun","Mon","Tue","Wed","Thu","Fri","Sat"  }; Static Const Charmon_name[][4] = {    "Jan","Feb","Mar","APR"," May","June",    "Jul"," the","Sep","Oct","Nov","Dec"  };  Static char result[ ]; sprintf (Result,"%.3s%.3s%3d%.2d:%.2d:%.2d%d\n", Wday_name[timeptr-Tm_wday], mon_name[timeptr-Tm_mon], timeptr->tm_mday, timeptr->Tm_hour, Timeptr->tm_min, timeptr->Tm_sec,1900+ timeptr->tm_year); return result;}

The doubt is lifted, and you can see that CTime returns a static local char array.

System call Lseek Change Open file location:

Handling Errors in system calls

Determine the type of error errno.

Display error message Perror:

The ls-a option lists hidden files:

How to write LS:

Stat gets file attribute information:

Where the structure of stat is:

Convert a pattern field to a character

To get the file type using a mask:

Unix/linux Programming Practice Tutorial (0:)

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.