一, 内存拷贝函数memcpy
内存拷贝函数需要头文件为:
C中为#include <memory.h>
或 #include <string.h>
C++中为#include <cstring>
或 #include <string>
代码解说:
数组farmer中存储10个农民伯伯的薪水(日薪,农民伯伯月收入过万很正常),将其中的数据拷贝到起始地址为salary的动态内存中
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void) {
int farmer[10] = {
160,230,100,650,490,330,550,454,780,300};
int num = 0;//农民伯伯数量
int *salary = NULL;
printf("请输入雇佣农民的数量:");
scanf_s("%d"