我有两个文件:file1和file2.如何追加内容file2以file1使内容file1持久化?
我知道我可以按成员复制结构成员,而不是我可以在结构上进行复制memcpy吗?
这样做是否明智?
在我的结构中,我有一个字符串也作为成员,我必须复制到具有相同成员的另一个结构.我怎么做?
在我的代码中,我收到此错误:
expected ‘const void *’ but argument is of type ‘struct in_addr’
Run Code Online (Sandbox Code Playgroud)
我使用memcmp我可以强制类型转换struct in_addr,以const void*作为const void * (struct in_addr )
可能重复:
从函数返回多个值
我有一个函数,必须返回两个值
return(&ptr->keys[pos].value)
return Duplicate;
Run Code Online (Sandbox Code Playgroud)
这里&ptr-> keys [pos] .value将给出地址,Duplicate是一个枚举值设置为2 ...如何将这两个值返回给另一个函数,insert_front这是一个链接列表这个&ptr-> keys [pos] .value用作链表的第一个地址.我应该写的调用函数的原型应该是什么?
#include<stdio.h>
#include<stdlib.h>
struct test
{
int x;
int *y;
};
main()
{
struct test *a;
a = malloc(sizeof(struct test));
a->x =10;
a->y = 12;
printf("%d %d", a->x,a->y);
}
Run Code Online (Sandbox Code Playgroud)
我得到o/p但是有一个警告
warning: assignment makes pointer from integer without a cast
Run Code Online (Sandbox Code Playgroud)
和
warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘int *’
Run Code Online (Sandbox Code Playgroud)
如何在struct test中输入值到*y