Software projects in the code, fewer than thousands of lines, many tens of thousands of lines, but not irregular to follow. After reading so much code, I found that two functions appear very frequently, and that is the memset () and memcpy () functions, which are often used in C language programming. After work, I looked up some information, and now make a brief description of them.
1. memset () function
(1) Function prototype
void *memset (void *dest, int c, size_t count).
(2) Function action
In MSDN, the function is described as: Sets buffers to a specified character, which is to set the cache to a special character. To put it simply, you set the value of the first count byte of the open memory space dest to value C.
(3) Application examples
/*************************************************************** * All rights reserved (C) 2014, Zhou Zhaoxiong.
* * File name: memset.c * Content Summary: For testing memset function * Other Description: No * current version: V1.0 * Author: Zhou * Completion Date: 20140329 * * Modify the Record 1://Modify history, including modified date, version number, modifier and modified content, etc. * Modified Date: * Version number: * Modified by: * Modified content: ******************
/#include <memory.h> #include <stdio.h> typedef signed Char INT8; Redefine data type typedef signed INT INT32; Redefining data Types/********************************************************************** * Function Description: main function * lose In parameter: no * output parameter: no * return value: No * other Description: No * Modified Date version number modify the content *---------------- --------------------------------------------------------------------------------------* 20140329 V1.0 Zhou create *******/INT32 Main (void) {INT8 szteststr[100
] = "AAAAAAAAAA";
printf ("The original string is:%s\n", SZTESTSTR); memset (szteststr, ' B ', 5);
Call the Memset function printf ("The changed string is:%s\n", SZTESTSTR);
return 0; }
The output of the program is:
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/project/