gpt4 book ai didi

c - 这个C声明代码有什么问题?

转载 作者:可可西里 更新时间:2023-11-01 11:36:17 26 4
gpt4 key购买 nike

#include <stdlib.h>
#include <Windows.h>
#include <Tchar.h>

HANDLE wHnd; // Handle to write to the console.
HANDLE rHnd; // Handle to read from the console.

int _tmain(int argc, _TCHAR* argv[]) {

// Set up the handles for reading/writing:
wHnd = GetStdHandle(STD_OUTPUT_HANDLE);
rHnd = GetStdHandle(STD_INPUT_HANDLE);

// Change the window title:
SetConsoleTitle(TEXT("Win32 Console Control Demo"));

// Set up the required window size:
SMALL_RECT windowSize = {0, 0, 79, 49};

// Change the console window size:
SetConsoleWindowInfo(wHnd, TRUE, &windowSize);

}

报告了一些像这样的错误:

'SMALL_RECT' : illegal use of this type as an expression  
missing ';' before identifier 'windowSize'

最佳答案

您正在使用仅支持现在古老的 C90 标准的 MS C 编译器。您的所有变量都必须在函数体的顶部声明。

int _tmain(int argc, _TCHAR* argv[])
{
// Set up the required window size:
SMALL_RECT windowSize = {0, 0, 79, 49};

// Set up the handles for reading/writing:
wHnd = GetStdHandle(STD_OUTPUT_HANDLE);
rHnd = GetStdHandle(STD_INPUT_HANDLE);

// Change the window title:
SetConsoleTitle(TEXT("Win32 Console Control Demo"));

// Change the console window size:
SetConsoleWindowInfo(wHnd, TRUE, &windowSize);
}

很痛苦,不是吗?!

关于c - 这个C声明代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10715525/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com