简单问题 char* 怎么转换为const unsigned chiar*

luckyfool 2004-04-26 03:06:40
如题,还有关于const 的和unsingned的数据类型应该怎么转换呢??
...全文
104 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
luckyfool 2004-04-26
  • 打赏
  • 举报
回复
这样好像可以

char *s = "sdfsdfsd";
const unsigned char* p = (const unsigned char*)(LPCTSTR)s;
减少库的使用,解决那些需要小代码量,但苦恼于没有简易的字符串处理函数的郁闷 char *itoa_private(int val, char *buf, unsigned radix);//整数转字符串 int my_isdigit(int ch);//判断字符是否为数字 long long StrToInt(const char *s,int sign);//字符串转数字 int atoi_32(const char *s);//将字符串str转换为32位整型,其正数的最值为0x7FFFFFFF,负数的最小值为0x80000000,考虑数字会溢出的情况 void LettersChange(unsigned char*str, unsigned char font);//大小写字母变成大小写字母 signed int st_strlen(unsigned char* str);//获取字符串长度 signed int st_strcmp(unsigned char *s,unsigned char *t);//比较两个字符串大小 unsigned char *st_strcpy(unsigned char *t,unsigned char *s);//字符串拷贝 signed int st_strncmp(unsigned char *dest,unsigned char *src,unsigned int Len);//可变长度字符串大小比较 signed char st_toupper(unsigned char c);//小写字符转化为大写字符 unsigned char *st_strcat(unsigned char *s,unsigned char *t);//字符串连接 signed int st_memcpy(unsigned char *dest, unsigned char *src, unsigned int Len);//可变长度内存拷贝 signed int st_memset(unsigned char *dest,unsigned char byte, unsigned int Len);//设置长度为Len的内存块为byte signed int st_memcmp(unsigned char* dest, unsigned char* src, unsigned int Len);//内存段内数据比较 int gsmInvertNumbers(const char* pSrc, char* pDst, int nSrcLength);//正常顺序的字符串转换为两两颠倒的字符串,若长度为奇数,补'F'凑成偶数 int gsmSerializeNumbers(const char* pSrc, char* pDst, int nSrcLength);//两两颠倒的字符串转换为正常顺序的字符串 int gsmEncode7bit(const char* pSrc, unsigned char* pDst, int nSrcLength);//7bit编码 int gsmDecode7bit(const unsigned char* pSrc, char* pDst, int nSrcLength);//7bit解码 int gsmString2Bytes(const char* pSrc, unsigned char* pDst, int nSrcLength);//可打印字符串转换为字节数据 int gsmBytes2String(const unsigned char* pSrc, char* pDst, int nSrcLength);//字节数据转换为可打印字符串
使用ZLIB库 包装的压缩解压缩文件的源码 VS2005 工程创建 /* */ class ZIPWRAP_EXP CZipper { public: CZipper(); virtual ~CZipper(); // simple interface static bool ZipFile(const char* szFilePath); // saves as same name with .zip static bool ZipFolder(const char* szFilePath, bool ignoreself = false); // saves as same name with .zip bool AddFolderToZipFile(const char*foldername, const char* rootfolder); bool AddFileToZipFile(const char*filename, const char*relfolder = NULL, const char* comment = NULL); bool AddFolderOnlyPathToFile(const char* foldername, const char* comment = NULL); bool OpenZipFile(const char* zipfilename, bool append = false); bool CloseZipFile(const char* global_comment = NULL); private: void* zipfile_;/* = NULL */ }; /* */ #define MAX_COMMENT (255) /* tm_unz contain date/time info */ typedef struct UZ_s { unsigned int tm_sec; /* seconds after the minute - [0,59] */ unsigned int tm_min; /* minutes after the hour - [0,59] */ unsigned int tm_hour; /* hours since midnight - [0,23] */ unsigned int tm_mday; /* day of the month - [1,31] */ unsigned int tm_mon; /* months since January - [0,11] */ unsigned int tm_year; /* years - [1980..2044] */ } UZ_s; // create our own fileinfo struct to hide the underlying implementation struct UZ_FileInfo { char szFileName[260 + 1]; char szComment[255 + 1]; unsigned long dwVersion; unsigned long dwVersionNeeded; unsigned long dwFlags; unsigned long dwCompressionMethod; unsigned long dwDosDate; unsigned long dwCRC; unsigned long dwCompressedSize; unsigned long dwUncompressedSize; unsigned long dwInternalAttrib; unsigned long dwExternalAttrib; bool bFolder; UZ_s tmu_date; }; class ZIPWRAP_EXP CUnZipper { public: CUnZipper(); virtual ~CUnZipper(); // simple interface static bool UnZip( const char* filename, const char* dstfolder, bool ingorepath = false, const char* password = NULL); bool OpenUnZipFile(const char* filename); bool CloseUnZipFile(); bool UnZipTo( const char* dstfolder, bool ingorepath = false, const char* password = NULL); int GetFileCount(); bool GotoFirstFile(); bool GotoNextFile(); bool GotoZipFile(int index); bool GotoZipFile(const char* zipfilename); bool GetCurrentFileInfo(UZ_FileInfo&fileinfo;); bool UnCurrentZipFile(const char* dstfolder, bool ingorepath = false, const char* password = NULL); bool UnOneZipFile(const char* filename, const char* dstfolder, bool ingorepath = false, const char* password = NULL); bool UnOneZipFile(int index, const char* dstfolder, bool ingorepath = false, const char* password = NULL); private: void* unzipfile_; };

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧