⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binary.c

📁 哈夫曼压缩程序
💻 C
字号:
#include<stdio.h>
#include<stdlib.h>

#include"binary.h"
#include"N_error.h"
#include"file.h"

/**********  make *C's position bit equals to b's position bit;**************************/
void WriteBitToC(unsigned char *C,char b ,char position)/*0 <= position <= 7 && b == 0 or b == 1  make *C's position bit equals to b's position bit;*/
{
	unsigned char temp = 1;
	if(position < 0 || position > 7 || b < 0 || b > 1)
	{
		N_ERROR("in function WriteBitToC there must 0 <= position <= 7 && b == 0 or b == 1");
		exit(0);
	}
	else
	{
		b <<= position;
		temp <<= position;
		temp = ~temp;      //set the position bit of temp 0;
		*C = *C & temp;    //set the position bit of *C 0;
		*C = *C | b;	//make *C's position bit equals to b's position bit;
	}
}

int WriteFullCToFile(int CIsfull,unsigned char *C,FILE *fp)
{
	if(CIsfull) //if the char was writed 8 bits then put it to file fp;
	{
		if( !WriteC(*C,fp,"at WriteFullToFile Cant not write to file when write Edges"))
			return 0;;
		*C = 0;
		return 1;
	}
	return 0;
}

/**********test main()****************************/
/*
void main()
{
	unsigned char c = 88;
	char b = 1, pos = 6;
	WriteBitToC(&c,b,pos);

}
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -