【C/C++】什么是链式编程?What Is Chain Programming?(English)

We know two common func - memset & memcpy, so we can use these two functions to show what's chain programming:

The inventer who invented these two fuctions left the definition like:

[memset]

void* memset(void* cbuff1, int ch, size_t n)

[strcpy]

void* memcpy(void* cbuff1, void* cbuff2, size_t n)

The reason that the inventor defined the return value type as void* is because that the fuction can be used like

int max_num = max(max(max(1,2),3),4) ;

[Example & Code]

char str1[100];

char str2[100];

memcpy(str2, memset(str1, 'o', 100), 100)

猜你喜欢

转载自blog.csdn.net/chenhanxuan1999/article/details/82974201