十六进制字符转对应的十六进制数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/guanjianhe/article/details/83958614
#include <stdio.h>
#include <string.h>


/* C 库函数 int feof(FILE *stream) 测试给定流 stream 的文件结束标识符。 */


int main( void )
{
	unsigned char	tmp;

	FILE	*infp;
	FILE	*outfp;


	infp	= fopen( "in.txt", "r" );
	outfp	= fopen( "out.txt", "wb" );

	/* 这边要先读再判断,不然会多出一个字节 */
	fscanf( infp, "%X", &tmp );

	while ( !feof( infp ) )
	{
		putc(tmp,outfp);
		fscanf( infp, "%X", &tmp );
	}

	fclose( infp );
	fclose( outfp );

	return(0);
}

猜你喜欢

转载自blog.csdn.net/guanjianhe/article/details/83958614