簡體   English   中英

這個C聲明代碼有什么問題?

[英]What's wrong with this C declaration Code?

#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);
}

痛苦,不是嗎?!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM