NCurses outputting vectors

The following code works perfectly with "normal" C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <vector>

int main()
{
    std::vector <std::string> hello
    {
    "#   #  #####  #      #      #####",
    "#   #  #      #      #      #   #",
    "#####  #####  #      #      #   #",
    "#   #  #      #      #      #   #",
    "#   #  #####  #####  #####  #####",
    };

    for (std::vector <std::string>::const_iterator it = hello.begin(); it != hello.end(); it++)
        std::cout << *it << std::endl;

    return 0;
}


This prints "HELLO" on the screen.
A function a bit more like NCurses is:
1
2
3
4
5
    for (std::vector <std::string>::const_iterator it = hello.begin(); it != hello.end(); it++)
    {
        std::string temp = *it;
        std::cout << temp.c_str() << std::endl;
    }

This still works with "normal" C++

Now, how do I get this working with NCurses?

I tried
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <curses.h>
#include <string>
#include <vector>

int main()
{
    initscr();

    std::vector <std::string> hello
    {
    "#   #  #####  #      #       #####",
    "#   #  #      #      #       #   #"
    "#####  #####  #      #       #   #",
    "#   #  #      #      #       #   #",
    "#   #  #####  #####  #####   #####",
    };

    for (std::vector <std::string>::const_iterator it = hello.begin(); it != hello.end(); it++)
    {
        std::string temp = *it;
        printw ( "%s \n", temp.c_str() );
    }

    endwin();

    return 0;
}


But this just gives me an empty screen.
Could anyone help me out, please?
Sorry for posting too soon. I figured this out myself. I won't delete the topic, in case somebody else needs this.
Here's the answer:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <curses.h>
#include <string>
#include <vector>

int main()
{
    initscr();
    clear();

    std::vector <std::string> hello
    {
    "#   #  #####  #      #       #####",
    "#   #  #      #      #       #   #",
    "#####  #####  #      #       #   #",
    "#   #  #      #      #       #   #",
    "#   #  #####  #####  #####   #####",
    };

    for (std::vector <std::string>::const_iterator it = hello.begin(); it != hello.end(); it++)
    {
        std::string temp = *it;
        printw ( "%s \n", temp.c_str() );
    }

    refresh();
    getch();
    endwin();

    return 0;
}
We don't need that vector.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>

int main()
{
    std::string hello = R"(
    #   #  #####  #      #      #####
    #   #  #      #      #      #   #
    #####  #####  #      #      #   #
    #   #  #      #      #      #   #
    #   #  #####  #####  #####  #####
    )" ; // http://www.stroustrup.com/C++11FAQ.html#raw-strings

    std::cout << hello ;
}

http://ideone.com/T8tqoG
Topic archived. No new replies allowed.