#include <stdio.h> #include <assert.h>void my_strcpy (char *dest,const char *src) {assert (dest!=null);//Assert ASSERT (Src!=null);//Assert while (*dest++=*src++) {;}} int main () {char name[10]={0}; char *p= "it__bit"; my_strcpy (name,p); printf ("%s\n", name); return 0;}
Assert assert () "header file" #include <assert.h>
For example: Assert (N<10);//Assert--if n>10, run the program will error
Assertion: Expressed as some boolean expression, the programmer believes that the expression value is true at a particular point in the program and can enable and disable assertion validation at any time, so you can enable assertions at test time and disable assertions at deployment time. Similarly, the end user can re-enable assertions when a problem is encountered after the program is put into operation.
Assertions can only function in debug, not in release, and release optimizes assert.
This article is from the "Pzd Chuan Feng" blog, please make sure to keep this source http://xujiafan.blog.51cto.com/10778767/1710491
Define my_strcpy function to implement strcpy function function