CStringCHUS
时间: 2024-04-15 19:30:52 浏览: 14
CString 是 MFC 中广泛使用的字符串类,它可以方便地进行字符串的操作。初始化 CString 可以使用以下几种方式:
1. 使用构造函数进行初始化:
```
CString str("Hello World!");
```
2. 使用赋值运算符进行初始化:
```
CString str;
str = "Hello World!";
```
3. 使用 Format 函数进行初始化:
```
CString str;
str.Format("%s %s", "Hello", "World!");
```
4. 使用 LoadString 函数从资源文件中读取字符串进行初始化:
```
CString str;
str.LoadString(IDS_HELLO_WORLD);
```
其中,IDS_HELLO_WORLD 是定义在资源文件中的字符串 ID。
相关推荐
![jpg](https://img-home.csdnimg.cn/images/20210720090814.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)