- 1. File operations: FILE structure, fprint / fgets, fwrite / fread, ftell / rewind / fseek, fflush
- 2.目录操作:getcwd,chdir,opendir,readdir,closedir,stat,utime,rename,remove
- 3. Operation Time: time_t data type, time (), tm structure, localtime (), mktime (). timeval, timezone, gettimeofday ()
- 4. The system error messages: strerror (), perror ()
- 5. preprocessor: -E, Macro
- 6.gdb Debug: set args, b, r, n, s
- 7.makefile file: dependency files function
1. File operations: FILE structure, fprint / fgets, fwrite / fread, ftell / rewind / fseek, fflush
ls -l
Depending on the organization of data in the file, the file can be divided into text and binary files
1. Text file
2. binary
file pointer
to open the file
close file: int fclose (FILE * fp) ;
read text file write: text files stored in units of strings, such as C program source code, such as a text, it is generally by line write or read data
vi /tmp/test1.txt, visible five rows, no matter how many executed times are 5 rows, because the file open mode is w, each time the file is opened are emptied original recorded file
reading and writing binary file
GCC -o book115 book115.c
VI /tmp/test1.dat
file buffer
standard input / O / error
the following information is parsed xml:
2.目录操作:getcwd,chdir,opendir,readdir,closedir,stat,utime,rename,remove
Get the current directory
Change directory
to create and delete directories
get a list of files in a directory, similar to the ls command
2. library functions
we are only concerned d_type structure (described file types, there are a variety of values, most importantly, 8 and 4 , 8 regular file, 4-directory) and d_name (file or directory name) members, other do not care about
the following to automatically create a subdirectory
macro equivalent of typedef, define an alias
1.stat structure
2.stat library functions
utime library functions
3. Operation Time: time_t data type, time (), tm structure, localtime (), mktime (). timeval, timezone, gettimeofday ()
Alias time_t
time_t time (time_t * t): returns time_t, following a time libraries
ld long integer, the random number seed is a time (0) generated by
providing a series of functions and the following C language structure to solve the above required number of days, and so on which year, .h file structure may be defined
accurate to the microsecond timer
sys / time.h header file system is linux
time_t from. to. the total number of seconds, strtime is "2019 -02-08 .... " May intercepted two characters, the address offset. Therefore, write "2019-02-08 ..." instead of "2019-2-8 ...", for convenience of address offset with the interception, "2019-2-8 ..." this form required by the - or: slicing string
obtained as the integral time timer, to make integral time offset. If the structure is defined as nowtimer * nowtimer pointer, pointer appear below are nowtimer (localtime since the return address, so the front localtime not starred variant pointer to fetch the address value), nowtimer.tm_year replaced nowtimer-> tm_year.
4. The system error messages: strerror (), perror ()
strerror library functions
concern error purpose is to obtain more detailed error information, error messages may be helpful for programmers diagnostic procedures, but not required.
5. preprocessor: -E, Macro
-E parameter is the pretreatment, # include those that can be seen in the contents of the file header file book.E
preprocessing directives
1 include file
2. macro definition instruction
without macro parameters defined in the following format:
macro arguments:
3. Conditions compile: the two most common formats #ifdef and #ifndef
follows book145.c and _public.c have #include "_public.h", repeats contain
the following written in _public.h in, _public.h not will be repeated contains
3. #undef: cancel identifier defined
6.gdb Debug: set args, b, r, n, s
Multi-feed / thread can not use gdb debugger, or use printf, but the results will not show to the screen, written to a log file. root user: yum -y install gdb, gdb -v
7.makefile file: dependency files function
make is a command tool, the tool is a command in the makefile instructions explain, in general, most compilers have this command, you can make use of a number of re-compiled minimized. File name makefile. vi gcc.sh follows, sh gcc.sh
above, if only to compile book2, a single file without recompiling other files change i.e. incremental compilation. vi makefile, before a tab key can not be $ 8 spaces.
The default is to make all make, if all this line book3 deleted, the compiler will not make book3, you can specify the make book3, book3 equivalent label.
- Euro 2 is to get the highest coding efficiency, generally with the official release.