Function to print 2D vector (win32api)

This function is supposed to print a vector<vector<char> >, but it doesn't seem to be working properly. Any idea why it won't work?

1
2
3
4
5
6
7
8
9
10
11
12
13
    void PrintMap()
    {
        //ClearScreen();
        HANDLE cppstdout = GetStdHandle(STD_OUTPUT_HANDLE);
        unsigned long cChars;
        for (int printy=0; printy<=yres-1; printy++)
        {
            std::string str(CharGrid[printy].data(), CharGrid[printy].size());
            SetConsoleCursorPosition(cppstdout,{0,0});
            WriteConsole(cppstdout, str.c_str(), lstrlen(str.c_str()), &cChars, NULL);
            WriteConsole(cppstdout, "\n", lstrlen("\n"), &cChars, NULL);
        };
    };
Bump
This function is supposed to print a vector<vector<char> >, but it doesn't seem to be working properly.

What does "it doesn't seem to be working properly" mean? Why withhold that information from us? (And why bump your post without providing more information less than two hours after you first posted it? After all, presumably you'd had two hours to try and fix whatever the problem was that you didn't bother to describe.)

But I'll take a stab in the dark. You print every line at the same location. That probably isn't what you wanted to do. See line 9.
Topic archived. No new replies allowed.