Having problems with my c++ void function?

2016-03-30 7:22 pm
I am trying to output the result from the void function into the file that is user generated. The problem is it works without outputting to a file but once I try to output to a file it does not work. Any help? Here is my code.
http://codepad.org/yVbi0uRN

回答 (1)

2016-03-30 7:47 pm
Your are re-declaring "ofstream outputFile" in main(), so the file is opened using that [a local variable] rather than the global version.

Either remove it / make it an external or pass the file/stream to the function as one of the parameters, in a similar way to functions such as fprinf()


收錄日期: 2021-05-01 20:33:51
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20160330112204AA8gDqY

檢視 Wayback Machine 備份