LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 775|回复: 0

那位给看看POP3的问题出在那里?

[复制链接]
发表于 2005-3-31 09:37:13 | 显示全部楼层 |阅读模式
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.h>
#include<sys/uio.h>

struct testvector {
int a;
char b[10];
};
//#define LEN (sizeof(struct testvector))
int main(){
int fd=open("files.txt",O_RDWR|O_CREAT|O_TRUNC,0644);
struct iovec iv,iv2;
struct testvector xx,pxx;// if use malloc,then here is *pxx
int LEN=sizeof(struct testvector);
xx.a=100;
strcpy(xx.b,"aaaaaa");
iv.iov_base=&xx;
iv.iov_len=LEN;

writev(fd, &iv,1);

close(fd);
fd=open("files.txt",O_RDONLY);

iv2.iov_base=&pxx; // malloc(LEN);
iv2.iov_len=LEN;
readv(fd, &iv2,1);
//      pxx=(struct testvector *)(iv2.iov_base);
printf("%d--%s\n",pxx.a,pxx.b);
//      printf("%d--%s\n",pxx->a,pxx->b);
return 0;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表