c语言 字符串 指针显示,怎么将一个字符串指针中的数据显示出来

如何将一个字符串指针中的数据显示出来?

如何将一个字符串指针(char *pBuf)中的数据显示出来?

当然这样也可以:

char buf[100]={0};

strcpy(buf, pBuf);

printf(buf);

------解决方案--------------------

void HexDump(char *buf,int len) {

int i,j,k;

char binstr[80];

for (i=0;i

if (0==(i%16)) {

sprintf(binstr,"%04x -",i);

sprintf(binstr,"%s %02x",binstr,(unsigned char)buf[i]);

} else if (15==(i%16)) {

sprintf(binstr,"%s %02x",binstr,(unsigned char)buf[i]);

sprintf(binstr,"%s  ",binstr);

for (j=i-15;j<=i;j++) {

sprintf(binstr,"%s%c",binstr,('!'

}

printf("%s\n",binstr);

} else {

sprintf(binstr,"%s %02x",binstr,(unsigned char)buf[i]);

}

}

if (0!=(i%16)) {

k=16-(i%16);

for (j=0;j

sprintf(binstr,"%s   ",binstr);

}

sprintf(binstr,"%s  ",binstr);

k=16-k;

for (j=i-k;j

sprintf(binstr,"%s%c",binstr,('!'

}

printf("%s\n",binstr);

}

}

#pragma comment(lib,"crypt32")

#include 

#include 

#include 

//+-------------------------------------------------------------------------

// convert formatted string to binary

// If cchString is 0, then pszString is NULL terminated and

// cchString is obtained via strlen() + 1.

// dwFlags defines string format

// if pbBinary is NULL, *pcbBinary returns the size of required memory

// *pdwSkip returns the character count of skipped strings, optional

// *pdwFlags returns the actual format used in the conversion, optional

//--------------------------------------------------------------------------

BOOL

WINAPI

CryptStringToBinaryA(

IN     LPCSTR  pszString,

IN     DWORD     cchString,

IN     DWORD     dwFlags,

IN     BYTE     *pbBinary,

IN OUT DWORD    *pcbBinary,

OUT    DWORD    *pdwSkip,    //OPTIONAL

OUT    DWORD    *pdwFlags    //OPTIONAL

);

//+-------------------------------------------------------------------------

// convert formatted string to binary

// If cchString is 0, then pszString is NULL terminated and

// cchString is obtained via strlen() + 1.

// dwFlags defines string format

// if pbBinary is NULL, *pcbBinary returns the size of required memory

// *pdwSkip returns the character count of skipped strings, optional

// *pdwFlags returns the actual format used in the conversion, optional

//--------------------------------------------------------------------------

BOOL

WINAPI

CryptStringToBinaryW(

IN     LPCWSTR  pszString,

IN     DWORD     cchString,

IN     DWORD     dwFlags,

IN     BYTE     *pbBinary,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值