: correct; GNU: Correct(char *) pvoid + = 1; ANSI: Error; GNU: correctThere are some differences between GNU and ANSI, and in general, the GNU is more "open" than ANSI, providing support for more grammars. But when it comes to real design, we should try to cater toANSI Standard.Rule four if the parameter of a function can be any type of pointer, then declare its argument to be void *Typical function prototypes, such as memory manipulation functions memcpy
memory manipulation functions memcpy and memset, are:void * memcpy (void *dest, const void *SRC, size_t len);void * memset (void * buffer, int c, size_t num);Thus, any type of pointer can be passed into memcpy and memset, which also truly embodies the meaning of the memory manipulation function, because the object it operates is only a piece of memory, regardles
++; ANSI: correct; GNU: Correct(char *) pvoid + = 1; ANSI: Error; GNU: correctThere are some differences between GNU and ANSI, and in general, the GNU is more "open" than ANSI, providing support for more grammars. But when it comes to real design, we should try to cater toANSI Standard.Rule IVif the argument to a function can be any type of pointer, declare that its argument is void *Typical function prototypes, such as memory manipulation functions memcpy
such as memcpy and memset are:
Void * memcpy (void * DEST, const void * SRC, size_t Len );Void * memset (void * buffer, int C, size_t num );
In this way, any type of pointer can be passed into memcpy and memset, which truly reflects the significance of the memory operation function, because the object it operates on is only a piece of memory, regardless of the m
function prototypes for memory operation functions such as memcpy and memset are: Void * memcpy (void * DEST, const void * SRC, size_t Len );Void * memset (void * buffer, int C, size_t num ); In this way, any type of pointer can be passed into memcpy and memset, which truly reflects the significance of the memory operation function, because the object it opera
operation functions such as memcpy and memset are:
Void * memcpy (void * DEST, const void * SRC, size_t Len );Void * memset (void * buffer, int C, size_t num );In this way, any type of pointer can be passed into memcpy and memset, which truly reflects the significance of the memory operation function, because the object it operates on is only a piece of memory,
pointer to PTR.
Note: The parameter value is declared as int, but must be unsigned char, so the range is between 0 and 255.
Example:Copy a plain text new window
#include
Execution results:
-------C.biancheng.net
The difference between Memmove and memcpymemcpy and Memmove () are the library functions in C language, in the header file string.h, the role is to copy a certain length of memory content, the prototype is as follows:
void *
class (except static) exist in the space of the Child class ).
3. the sprintf, strcpy, and memcpy functions can be used to complete string copying. What are the differences between these functions? Which one do you like and why?
Answer: The difference between these functions is that they implement different functions and operate on different objects.1. The strcpy function operates on a string to copy the source string to the target string.2. snprintf
exception ", in the exception handling function, read the data or commands into the memory and re-execute the interrupted program. This saves memory and allows the operating system to run such programs, they use much larger memory than the actual physical memory.
In the original kernel version, the kernel calls the trap_init and init_irq functions in the start_kernel function (the source code is in init/Main. c) to set exceptions and handling functions. In the kernel version of linux2.6.32.2 (
char * s to Char s []
3. The memset () function is often used for memory space initialization. For example:
Char STR [100];
Memset (STR, 0,100 );
4. Deep connotation of memset (): it is used to set all memory space to a specific character. It is generally used to initialize the defined string to 'memset (A, '\ 0 ', sizeof ());
Memcpy is used for memory copying. You can use it to copy any data type object and specify the length of the copied data. For
(char*buf,intsize);/* reduces the number of contiguous spaces inside a string to 1 spaces */void Reduce_space (char*buf,intsize); Intsplit (constchar*buf_in,intsize_in, Char*buf[],intsizE,charseparator); Voidsplit_free (char*buf[],intsize); #endif Source code: MY_STRING.C#include #include #include /* Determine if the given string is a hexadecimal number */int Is_hex (const char* val,int size){int status = 1;char* buf_tmp = malloc (size+1);memset (buf_tmp,0,size+1);
; } sck_handle*sh =NULL; SH= (Sck_handle *) handle; //open up memory space for newspaper charactersSh->buf = (Char*)malloc(sizeof(Char)*Buflen); if(sh->buf==NULL) {erro_msg=3; printf ("Sh->buf==null memory allocation failure erro msg:%d\n", erro_msg); returnerro_msg; } //Assigning a value to a text character in a context//memcpy () function explanation//function Prototypes//void *memcpy (void *dest, cons
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.