C language functions are available every day

Source: Internet
Author: User

Summarize the C language functions encountered during the learning process:

1. Related functions: fstat, lstat, chmod, chown, readlink, and utime

Header file: # include # Include
Define the function: int stat (const char * file_name, struct stat * buf );
Function Description: stat () is used to copy the state of the file referred to by the parameter file_name to the structure referred to by the parameter buf. 0 is returned for success, and-1 is returned for failure. details in the stat structure are not described in detail. You can refer to other blog materials.

Usage:

struct stat sa;if(stat(filename,&sa)<0){return -1;}....
2. memset

Purpose: set the value of the first n Bytes of the memory space s to the value c.

# Include
   
    
Using namespace std; void main () {char s [20]; cout <"s size" <
    
     

3. rand (), RAND_MAX

Rand () is a random function that generates random numbers;

RAND_MAX is a character constant defined by macro in stdlib. h In C: # define RAND_MAX Ox7FFF has a minimum value of 32767 and a maximum value of 2147483647. RAND_MAX can be used to generate random decimal places.
#include
      
       #include
       
        #include
        
         using namespace std;int main(void){srand((unsigned int)time(NULL));double a[10];int i;cout<
         
          



Related Article

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.