malloc分配内存-----一个有错
来源:互联网 发布:淘宝号码没有信誉 编辑:程序博客网 时间:2024/06/06 09:22
#include <stdio.h>
#include <stdlib.h>
char * init(char *p)
{
p = malloc( sizeof(char)) ;
if( !p )
{
printf("p is NULL !\n");
return NULL ;
}
return p ;
}
char * init_test(char **p)
{
*p = malloc( sizeof(char)) ;
if( !*p )
{
printf("*p is NULL !\n");
return NULL ;
}
return *p ;
}
char * init_char()
{
char *p = malloc( sizeof(char)) ;
if( !p )
{
printf("p is NULL !\n");
return NULL ;
}
return p ;
}
int main()
{
char * test = NULL ;
test = init_char();
if( !test )
{
printf("p is NULL !\n");
}
char * xiejian = NULL;
init(xiejian);
if( !xiejian )
{
printf("xiejian is NULL !\n");
}
char *test2 = NULL ;
init_test( &test2 );
if( !test2 )
{
printf("test2 is NULL !\n");
}
return 0;
}
#include <stdlib.h>
char * init(char *p)
{
p = malloc( sizeof(char)) ;
if( !p )
{
printf("p is NULL !\n");
return NULL ;
}
return p ;
}
char * init_test(char **p)
{
*p = malloc( sizeof(char)) ;
if( !*p )
{
printf("*p is NULL !\n");
return NULL ;
}
return *p ;
}
char * init_char()
{
char *p = malloc( sizeof(char)) ;
if( !p )
{
printf("p is NULL !\n");
return NULL ;
}
return p ;
}
int main()
{
char * test = NULL ;
test = init_char();
if( !test )
{
printf("p is NULL !\n");
}
char * xiejian = NULL;
init(xiejian);
if( !xiejian )
{
printf("xiejian is NULL !\n");
}
char *test2 = NULL ;
init_test( &test2 );
if( !test2 )
{
printf("test2 is NULL !\n");
}
return 0;
}
- malloc分配内存-----一个有错
- malloc free内存分配
- malloc内存分配机制
- malloc内存分配
- malloc内存分配
- c malloc分配内存
- malloc内存分配详解
- c malloc分配内存
- malloc内存分配原理
- malloc分配内存失败
- malloc 内存分配
- 内存分配malloc
- malloc内存分配
- 动态内存分配malloc
- malloc分配内存失败
- 内存分配学习(一)-- 实现一个malloc
- 内存分配,malloc()和free()
- 内存分配 malloc()和calloc()
- 瓦刀发布,必属精品:Domino评审、表决系统
- 技巧_MFC_编辑框_换行
- 关于Hibernate的日志
- Java的身份证号码工具类
- Gate Level Modeling Part-I (of Verilog HDL)
- malloc分配内存-----一个有错
- [OpenCV]:Visual Studio 2012 搭建 OpenCV2.4.3
- 一次优化记录
- 需要仔细研究的技术
- 同步和异步的区别
- 一个 Linux 上分析死锁的简单方法
- ubuntu12.04 “flash 设置” 无法点击
- VC调试
- android中listView下拉刷新