C语言结构体之间相互拷贝
作者:
阿群1986 | 来源:发表于
2019-08-05 14:02 被阅读0次#include <stdio.h>
#include <string.h>
struct MyRecord {
char data_buf[20];
unsigned int len;
};
int main()
{
struct MyRecord x;
x.data_buf[0] = 'H';
x.data_buf[1] = 'e';
x.data_buf[2] = 'l';
x.data_buf[3] = 'l';
x.data_buf[4] = 'o';
x.data_buf[5] = '\0';
x.len = strlen(x.data_buf);
printf("x.data_buf[] = %s\n", x.data_buf);
printf("x.len = %u\n", x.len);
struct MyRecord y = x; // 结构体对拷
printf("y.data_buf[] = %s\n", y.data_buf);
printf("y.len = %u\n", y.len);
return 0;
}
本文标题:C语言结构体之间相互拷贝
本文链接:https://www.haomeiwen.com/subject/oqcmdctx.html
网友评论