Jump to content
  • Advertisement
Sign in to follow this  
dpadam450

help with CHAR_INFO

This topic is 4593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have to make a text based game. I am outputting the text with WriteConsole(); I get the error : cannot convert 'CHAR_INFO'
  • [80] to 'const CHAR_INFO*' CHAR_INFO mapArray[50][80]; // thats my CHAR_INFO any help?

    Share this post


    Link to post
    Share on other sites
    Advertisement
    CHAR_INFO mapArray[50][80];


    COORD gridSize = {80,50};
    COORD startPos = {0,0};
    SMALL_RECT rect = {0,0,80,50};
    SMALL_RECT* rectP = ▭
    HANDLE hStdout;
    hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

    WriteConsoleOutput(hStdout,mapArray, gridSize, startPos, rectP);

    //i load an array from file called temp_array and then run a for loop to copy it
    // to mapArray

    Share this post


    Link to post
    Share on other sites
    CHAR_INFO mapArray[50][80]

    is pretty much a CHAR_INFO**, because its a pointer to a pointer which points to some memory.


    mapArray --> CHAR_INFO* --> CHAR_INFO

    It looks something like that. Anyway, I'm fairly sure that you have to do whatever it is that you're doing line by line. So, have a loop and instead of "WriteConsoleOutput(hStdout,mapArray, gridSize, startPos, rectP);", you need to replace "mapArray" with "mapArray"

    Hope that helped.

    Share this post


    Link to post
    Share on other sites
    You've managed to pass a 2D array to WriteConsoleOutput () as a pointer to CHAR_INFO, it should be written as:
    WriteConsoleOutput (hStdout, reinterpret_cast<CHAR_INFO const*> (mapArray), gridSize, startPos, rectP) ;
    Quote:
    Original post by Endar
    you need to replace "mapArray" with "mapArray"
    It won't work as expected as the function treat the buffer as a 2D array:
    Quote:
    lpBuffer
    [in] Pointer to a source buffer that contains the data to be written to the console screen buffer. This pointer is treated as the origin of a two-dimensional array of CHAR_INFO structures whose size is specified by the dwBufferSize parameter. The total size of the array must be less than 64K.

    Share this post


    Link to post
    Share on other sites
    It did work with mapArray[50]. not sure why but im glad it works. The other kid on my team didn even do that and his works just fine so who knows.

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by Skeleton_V@T
    You've managed to pass a 2D array to WriteConsoleOutput () as a pointer to CHAR_INFO, it should be written as:
    WriteConsoleOutput (hStdout, reinterpret_cast<CHAR_INFO const*> (mapArray), gridSize, startPos, rectP) ;
    Quote:
    Original post by Endar
    you need to replace "mapArray" with "mapArray"
    It won't work as expected as the function treat the buffer as a 2D array:
    Quote:
    lpBuffer
    [in] Pointer to a source buffer that contains the data to be written to the console screen buffer. This pointer is treated as the origin of a two-dimensional array of CHAR_INFO structures whose size is specified by the dwBufferSize parameter. The total size of the array must be less than 64K.


    Aha! It apparently doesn't help if you look up "WriteConsole" instead of the right funtion.

    Share this post


    Link to post
    Share on other sites
    You're probably right. But at first the OP mentioned WriteConsole (), later he posted the code that refers WriteConsoleOutput(hStdout,mapArray, gridSize, startPos, rectP); instead.
    Quote:
    It did work with mapArray[50]. not sure why but im glad it works. The other kid on my team didn even do that and his works just fine so who knows.

    I'm not sure I understand what you meant, did you work it out or not ?.

    Share this post


    Link to post
    Share on other sites
    Sign in to follow this  

    • Advertisement
    ×

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!