如何将一个字符串指针中的数据显示出来?
如何将一个字符串指针(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,