Skip to content

Instantly share code, notes, and snippets.

@eraserhd
Created September 8, 2014 19:34
Show Gist options
  • Select an option

  • Save eraserhd/c3b0b7cbea65239d80c6 to your computer and use it in GitHub Desktop.

Select an option

Save eraserhd/c3b0b7cbea65239d80c6 to your computer and use it in GitHub Desktop.
Some curses stuff
#include <curses.h>
#include <iostream>
#include <string>
std::string myfunc()
{
std::string result = "Hello, World!";
return result;
}
int main()
{
initscr(); // Prolly need to do more setup-y things
std::string what_to_show = myfunc();
addstr(what_to_show.c_str());
char buf[256];
getstr(buf); // getstr writes into buf
std::string a_c_plus_plus_string = buf; // Convert C-style character buffer to C++ string.
endwin();
std::cout << "you typed: " << a_c_plus_plus_string << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment