如何在C++中调用字符串资源

Dap*_*apu 4 string resources visual-c++

在resource.h中

#define String1 333
Run Code Online (Sandbox Code Playgroud)

在resource.rc中

#include <windows.h>
#include "resource.h"

STRINGTABLE
{
    STRING1                   "hie people"
}
Run Code Online (Sandbox Code Playgroud)

在main.cpp中

#include<iostream.h>
#include<resource.h>
#include<windows.h>
using namespace std;
int main{
cout<<here i want to output string value from resource how to call the string;
}
Run Code Online (Sandbox Code Playgroud)

还有一个我在代码块中编译的问题.就是说resource.h不存在我错的地方

Aam*_*mir 8

我假设它是Visual C++,你正在使用MFC.它就像调用一样简单:

::LoadString(...)
Run Code Online (Sandbox Code Playgroud)

如果你正在使用MFC,那么

CString str;
str.LoadString(STRING1)
Run Code Online (Sandbox Code Playgroud)

来自MSDN的LoadString

这里有一个如何使用LoadString的示例