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<