realloc 使用例子
来源:互联网 发布:弘历软件上班时间 编辑:程序博客网 时间:2024/05/17 07:18
#include "cvector.h"
#include"stdio.h"
#include <memory.h>
int main()
{
char* alloutbuf = NULL;
size_t nout = 10;
size_t nsize = 0;
int ns[3] = { 3, 2, 5 };
char* pp[] = { "123", "ab", "567" };
int i = 0;
while ( i < 3 )
{
nout = ns[i];
char* outbuf = (char*)malloc( nout );
strcpy( outbuf, pp[i] );
//int iRet = Media_GetByteArray( outbuf, &nout );
i++;
if ( outbuf )
{
alloutbuf = realloc( alloutbuf, nsize + nout );
memcpy( alloutbuf+nsize, outbuf, nout );
nsize += nout;
free( outbuf );
outbuf = NULL;
}
}
if ( alloutbuf )
{
free(alloutbuf);
alloutbuf = NULL;
}
return 0;
}
#include"stdio.h"
#include <memory.h>
int main()
{
char* alloutbuf = NULL;
size_t nout = 10;
size_t nsize = 0;
int ns[3] = { 3, 2, 5 };
char* pp[] = { "123", "ab", "567" };
int i = 0;
while ( i < 3 )
{
nout = ns[i];
char* outbuf = (char*)malloc( nout );
strcpy( outbuf, pp[i] );
//int iRet = Media_GetByteArray( outbuf, &nout );
i++;
if ( outbuf )
{
alloutbuf = realloc( alloutbuf, nsize + nout );
memcpy( alloutbuf+nsize, outbuf, nout );
nsize += nout;
free( outbuf );
outbuf = NULL;
}
}
if ( alloutbuf )
{
free(alloutbuf);
alloutbuf = NULL;
}
return 0;
}
0 0
- realloc 使用例子
- realloc函数的使用
- realloc的使用【转】
- realloc()函数的使用
- realloc 使用和思考
- realloc函数的使用
- realloc函数使用总结
- realloc函数的使用
- realloc
- realloc
- realloc
- realloc
- realloc
- realloc
- realloc
- realloc
- realloc
- realloc
- 实现类似iPhone的Notification-在Service中添加悬浮窗
- 倒排索引实现
- Supervisor Run Program as Non-root
- 常用svn指令总结
- BAT 修改系统环境变量
- realloc 使用例子
- 如何进行产品促销研究
- [转] android自定义布局中的平滑移动
- JSP中获取Session
- lua判断一个元素是否在表里
- 二叉树的遍历有三种方式
- Struts错误
- 表单设计的思考
- Android电话短信拦截项目总结之 开发工具