The second question is a little bit tougher than you probably anticipate- generally when I need the data output to a program's console (AKA stdout && stderr) I will use createProcess to open the program. However this only works in windows- and if you're using g++ i'm assuming your on a linux platform?