The variable "triangle" is local to your doBreak function. You need to have declare it in main and increment it depending on what doBreak returns.