无法从“int”转换为“int”到“int *”

发布于 2024-09-05 11:24:30 字数 368 浏览 8 评论 0原文

所以我有这些代码行:

int maxY, maxX;
getmaxyx(stdscr, &maxY, &maxX);

它给了我以下错误:

error C2440: '=' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

每次使用它两次。我什至没有使用 = 运算符!包含curses.h 文件。我做错了什么?

So I have these lines of code:

int maxY, maxX;
getmaxyx(stdscr, &maxY, &maxX);

It gives me the following error:

error C2440: '=' : cannot convert from 'int' to 'int *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

twice for each time I use it. I'm not even using the = operator! The curses.h file is included. What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

注定孤独终老 2024-09-12 11:24:30

getmaxyx 是一个宏,它接受的不是 int*,而是 int。
它解析为类似

getmaxyx(S,Y,X) -> X=s->X, Y=s->Y

尝试

getmaxyx(stdscr, maxY, maxX); // without the & operator

查看 http://opengroup.org/onlinepubs/007908775/xcurses /getmaxyx.html

getmaxyx is a macro, which doesn't take int*, but int.
It resolves to something like

getmaxyx(S,Y,X) -> X=s->X, Y=s->Y

try

getmaxyx(stdscr, maxY, maxX); // without the & operator

see http://opengroup.org/onlinepubs/007908775/xcurses/getmaxyx.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文