初期化文字列

書式#include <stdio.hに> 
する#include <stdlib.h>に含ま
する#include < 文字列の.h> 
の#include < 文字列 >
 使用して 名前空間はstdを、
チャーファイル[] = " hexstr.h " ブール str2hex(文字列 strの、名)
{ 
    FILEの *の浮動小数点=用のfopen(ファイル、" + " )。
    関数fprintf(FP、" %sのInit_の#define()はunsigned char%のS [%のD] = {0}; \\\ N "、name.c_str()、name.c_str()、str.length()+ 1 ); 
    関数fprintf(FP、" {\\\ N " );
    チャー BUF [ 10240 ] = { 0 }。
    sprintf(BUF、" %sの" 、str.c_str())。
    int型 I = str.length()/ 2 - 1 ; I> = 0 - ; I)
    { 
        fprintfの(FP、" %S [%のD] 0X%X =; \\\ N " 、name.c_str ()、I、BUF [I])。
    } 
    のためのint型 I = str.length()/ 2 ; iは(str.lengthを<); ++ I)
    { 
        fprintfの(FP、" %S [%のD] 0X%X =; \\\ N "、name.c_str()、I、BUF [I])。
    } 
    関数fprintf(FP、" } \\\ N " ); 
    FCLOSE(FP)。

    返す ; 
} 
int型のmain()
{ 
    ::削除(ファイル)。
    str2hex(" ダレン"" ユーザ" )。

    リターン 0 ; 
}

 

おすすめ

転載: www.cnblogs.com/yuandaozhe/p/11404769.html