AddBuffer
来源:互联网 发布:淘宝联盟软件推广赚钱 编辑:程序博客网 时间:2024/05/18 14:26
#include <stdio.h>
//#include <sys/unp.h>
#include <string.h>
int AddBuffer(char** dest,const char*src,int* left,int len)
{
int i = 0;
if(*left < len)
{
return -1;
}
memcpy(*dest,src,len);
*dest = *dest + len;
*left = *left - len;
/* while(i < len)
{
*(*dest) = *src++;
(*dest)++;
i++;
;
}
*left -= len;
*/
return 0;
}
struct test{
int uin;
int uin2;
char ch[0];
int jj;
};
void main()
{
char src[]="0123456789";
/* struct test* p = (struct test*)malloc(sizeof(struct test) + 200*2048);
printf("sizeof test is %d %lu %lu\n",sizeof(struct test),(char*)p->ch,&(p->jj));
strcpy((char*)p->ch,ch);*/
// printf("%lu %lu",(char*)p+8,p->ch);
// printf("===== %s\n",(char*)p->ch);
// printf("%s",CPU_VENDOR_OS);
char* dest = (char*)malloc(sizeof(char)*100);
char* p = dest;
memset(dest,'0',100);
int left = 100;
// printf("dest addr is %lu\n",dest);
// bcopy(ch,tt,strlen(ch)+1);
while(AddBuffer(&dest,src,&left,sizeof(src)-1) == 0);
int i = 0;
while(i < 100)
{
printf("%c",p[i]);
if(i%10 == 9) printf("\n");
i++;
}
// printf("%s",p);
free(p);
}
//#include <sys/unp.h>
#include <string.h>
int AddBuffer(char** dest,const char*src,int* left,int len)
{
int i = 0;
if(*left < len)
{
return -1;
}
memcpy(*dest,src,len);
*dest = *dest + len;
*left = *left - len;
/* while(i < len)
{
*(*dest) = *src++;
(*dest)++;
i++;
;
}
*left -= len;
*/
return 0;
}
struct test{
int uin;
int uin2;
char ch[0];
int jj;
};
void main()
{
char src[]="0123456789";
/* struct test* p = (struct test*)malloc(sizeof(struct test) + 200*2048);
printf("sizeof test is %d %lu %lu\n",sizeof(struct test),(char*)p->ch,&(p->jj));
strcpy((char*)p->ch,ch);*/
// printf("%lu %lu",(char*)p+8,p->ch);
// printf("===== %s\n",(char*)p->ch);
// printf("%s",CPU_VENDOR_OS);
char* dest = (char*)malloc(sizeof(char)*100);
char* p = dest;
memset(dest,'0',100);
int left = 100;
// printf("dest addr is %lu\n",dest);
// bcopy(ch,tt,strlen(ch)+1);
while(AddBuffer(&dest,src,&left,sizeof(src)-1) == 0);
int i = 0;
while(i < 100)
{
printf("%c",p[i]);
if(i%10 == 9) printf("\n");
i++;
}
// printf("%s",p);
free(p);
}
- AddBuffer
- Artificial Intelligence: A modern approach 3rd--Learning notes
- Oracle Virtualbox虚拟机下linux与主机共享文件
- qt html标签
- java环境变量设置
- Android运动事件的处理
- AddBuffer
- 项目空间都有啥
- 常见的链表题目
- spring 读取属性文件
- linq 2 xml 简单操作
- Python MySqlDB 增删修改数据库
- Linux 2.6.19.x 内核编译配置选项简介
- Open64业内外人士对LLVM和Open64的观点(转)
- c#操作access,出现“内部错误: 无效的参数访问器: 2 BADBINDINFO”的解决办法