随笔分类 - String
1
摘要:转载自:C++数据类型转换技巧类型转换是将一种类型的值映射为另一种类型的值。进行数据类型的转换。 是在实际代码编写中经常遇到的问题,特别是字符串和其他类型的转换。 1.将字符串转换为整数 (1).转换函数 // 双精度函数 double atof( const char *string ); double _wtof( const wchar_t *string ); 自适应 TC...
阅读全文
摘要:How to: Convert Between Various String Types
阅读全文
摘要:回车和换行有什么区别 回车 \r 本义是光标重新回到本行开头,r的英文return,控制字符可以写成CR,即Carriage Return 换行 \n 本义是光标往下一行(不一定到下一行行首),n的英文newline,控制字符可以写成LF,即Line Feed 在不同的操作系统下,ENTER对应的字符是不同的:UNIX下是\n;WIN下是\r\n;MAC下是\r
阅读全文
摘要:I met this issue on my laptop with English version XP installed. When installing wangwang from taobao.com, I met 乱码. I first thought it's due to the wangwang is not unicode-based. But I really don't t...
阅读全文
摘要:From MSDN: To simplify code development for various international markets, the Microsoft run-time library (CRT) provides Microsoft-specific "generic-text" mappings for many data types, routines, and o...
阅读全文
摘要:assert(CRT) #include void assert( int expression ); stdio.h VS cstdio If you are writing c code, please use stdio.h; if c++, please use cstdio. Functionally, these two header files are the same. One ...
阅读全文
摘要:Get it from: http://msdn.microsoft.com/zh-cn/magazine/cc188714(en-us).aspx In one word, in order to use STL string to be adaptive with Unicode, the best way is to define a tstring as follows: #includ...
阅读全文
摘要:Whatever platform an application runs on (windows, linux, mac, etc), the way to visit file system is through OS API (e.g: windows API). Take "get a file name" for example on windows, finally the name ...
阅读全文
摘要:[MSDN:http://msdn.microsoft.com/zh-cn/library/ms235631(VS.80).aspx] 从 char * 转换 示例 此示例演示如何从 char * 转换为上面列出的其他字符串类型。 复制代码 ...
阅读全文
摘要:1. '\0'----字符串结束符。代表了0x00。 2. strcpy,strcat等函数,期待'\0'在源字符串中的出现。必须出现才能copy或连接成功。 3. 最好在每次使用前均使用memset(&buf,0,sizeof(buf))清空数据区,保证没错
阅读全文
摘要:char string[1]; // string[10] is the boundary example to tell the extra '0' in a c style string will also be copied when copying. char *str1="0123456789"; strcpy(string, str1); // 11 char will be cop...
阅读全文
摘要:
阅读全文
摘要:1. 反转一个string const int SIZE = 100; char a[SIZE]; cin.getline(a, SIZE); size_t nChar = strlen(a); char chTmp; for(size_t i = 0, j = nChar-1; i < j; ++i, --j) { chTmp = a[i]; a[i] = a[j]; ...
阅读全文
摘要:string strValue; // STL string. cin >> strValue; strValue.replace(strValue.begin(), strValue.end(), strValue.rbegin(), strValue.rend()); cout << strValue; Please learn STL in deep!
阅读全文
摘要:Decimal -- 十进制 Octal -- 八进制 Hexadecimal(Hex) -- 十六进制 Binary -- 二进制 转义字符是C语言中表示字符的一种特殊形式。通常使用转义字符表示ASCII码字符集中不可打印的控制字符和特定功能的字符,如用于表示字符常量的单撇号( '),用于表示字符串常量的双撇号( ")和反斜杠( \)等。转义字符用反斜杠\后面跟一个字符或一个八进制或十六进制...
阅读全文
摘要:Now we have one Unicode string, and we want to convert it to be narrow string which means multi byte string and truncate it to desired length. There is one key point: in Unicode string, two bytes repr...
阅读全文
摘要:Introduction Since C-style strings can be error-prone and difficult to manage, not to mention a target for hackers looking for buffer overrun bugs, there are lots of string wrapper classes. Unfortunat...
阅读全文
摘要:Introduction You've undoubtedly seen all these various string types like TCHAR, std::string, BSTR, and so on. And then there are those wacky macros starting with _tcs. And you're staring at the screen...
阅读全文
摘要:char* lpStr = "shell-ai-天天向上.prt"CString strVal = lpStr;As a result, strVal won't have correct string.Solution:CString strVal = UTX_NTOM(lpStr).c_str();
阅读全文
摘要:Visual C++.NET涉及到ATL/ATL Server、MFC和托管C++等多种编程方式,不仅功能强大而且应用广泛。在编程中,我们常常会遇到ANSI、Unicode以及BSTR不同编码类型的字符串转换操作。本文先介绍基本字符串类型,然后说明相关的类,如CComBSTR、_bstr_t、CStringT等,最后讨论它们的转换方法,其中还包括使用最新ATL7.0的转换类和宏,如CA2CT、CA...
阅读全文
1

浙公网安备 33010602011771号