如何将变量赋给 const char *GetVersion()
的值?
我正在使用第三方库,该库声明 const char *GetVersion()
可用。下面的代码编译成功:
#include <iostream>
#include <Windows.h>
#include "ThirdPartyLibrary.h"
int main()
{
const char *GetVersion();
}
如何将 const char *GetVersion()
赋值给一个变量?
更新
char const *GetVersion()
The version of the Application manual interface that has loaded the running extension. This version is distinct from the API version, which is documented in Macros , below.
最佳答案
你的代码编译因为编译器理解
const char *Function();
作为一个函数原型(prototype)。
首先,阅读文档。看起来你可以简单地写
const char* my_variable = Function();
但是请检查您是否需要释放任何内存。 (我的直觉是你没有给定返回类型是 const
,但也许你需要回调到那个库中传递 my_variable
作为参数)。
关于c++ - 如何将 `const char *GetVersion()`(来自第三方库)分配给变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46151860/