一个c的基础的问题,第一次发帖,不知道分什么的东西。。。我用的是vs2005C/C++ code#include stdafx.h#inclu
一个c的基础的问题,第一次发帖,不知道分什么的东西。。。
我用的是vs2005
- C/C++ code
#include "stdafx.h"#include <cstring>typedef unsigned char *byte_pointer;void show_bytes(byte_pointer start, int len){ int i; for (i = 0; i < len; i++) { printf(" %.2x", start[i]); } printf("\n");}int _tmain(int argc, _TCHAR* argv[]){ char *s = "ABCDEF"; show_bytes(s, strlen(s)); return 0;}系统提示:error C2664: “show_bytes”: 不能将参数 1 从“char *”转换为“byte_pointer”
[解决办法]
这边的byte_pointer是unsigned char *
然后char *s = "ABCDEF";是char *的
你加个转化就可以了
show_bytes((byte_pointer)s, strlen(s));
