相关疑难解决方法(0)

2454
推荐指数
25
解决办法
111万
查看次数

使用"char"的布尔数组

我创建了一个实际上代表一个存储在char中的8个布尔数组的对象.我用它来学习更多关于按位运算符以及在C中创建自己的对象的内容.所以我有两个问题:

  1. 如果以下代码始终有效,我可以确定吗?
  2. 这是一个很好的实现,可以创建一个不会在C中丢失的对象,除非你自己发布它.

代码:

/*
 *  IEFBooleanArray.h
 *  IEFBooleanArray
 *
 *  Created by ief2 on 8/08/10.
 *  Copyright 2010 ief2. All rights reserved.
 *
 */

#ifndef IEFBOOLEANARRAY_H
#define IEFBOOLEANARRAY_H

#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef char * IEFBooleanArrayRef;

void IEFBooleanArrayCreate(IEFBooleanArrayRef *ref);
void IEFBooleanArrayRelease(IEFBooleanArrayRef ref);
int IEFBooleanArraySetBitAtIndex(IEFBooleanArrayRef ref, 
                                 unsigned index, 
                                 int flag);
int IEFBooleanArrayGetBitAtIndex(IEFBooleanArrayRef ref, 
                                 unsigned index);

#endif
Run Code Online (Sandbox Code Playgroud)
/*
 *  IEFBooleanArray.c
 *  IEFBooleanArray
 *
 *  Created by ief2 on 8/08/10.
 *  Copyright 2010 ief2. All rights reserved.
 *
 */

#include …
Run Code Online (Sandbox Code Playgroud)

c arrays malloc free boolean

3
推荐指数
1
解决办法
2541
查看次数

标签 统计

c ×2

arrays ×1

bit-manipulation ×1

bitwise-operators ×1

boolean ×1

c++ ×1

free ×1

malloc ×1