mvaddstr for a std::string variable?!

  • Kurgusov

    Kurgusov - 2007-06-16

    Hi Mr McBrine et al,thanks for dropping round to see us at game programmers wiki and answering the month old post bro ;).

    Anyway I cant seem to output a string with mvaddstr if that string is defined as follows...

    std::string line1 = "yiberdeyaba";

    Though I can with....

    char line1[] = "yiberdeyaba";

    Does this mean I cant use c++ strings (using the <string> header) with the addstr functions?
    Also Im not sure which version of pdcurses I have,is there a way of finding out
    inside the program?

    whatever happens Im having a ball with pdcurses :)

    • William McBrine

      William McBrine - 2007-06-16

      1. PDCurses is pure C. So, as with other C functions, you'd have to convert the string; e.g., by using "addstr(line1.c_str())" instead of just "addstr(line1)".

      2. At compile time, you can check the value of the PDC_BUILD define (available from 2.4 on). It's the version number * 100 (plus a largely meaningless build number). At run time, you could use the function curses_version(); however, it was only introduced in 3.0. There's also a const char *_curses_version, which goes back to 2.0, but it wasn't kept accurate until 2.8. (2.0 and 2.1 identify as 2.0; 2.2 through 2.7 as 2.2.)

    • William McBrine

      William McBrine - 2007-06-16

      P.S. Glad you're enjoying. :-)


Log in to post a comment.