+ 1

Opening an outputfile and giving it a name

How come line 43 outputfile.open(receiptName); works in Visual Studio 2017, but not in Code Blocks? https://pastebin.com/ueaXAHUz http://i.imgur.com/slcIubm.png http://i.imgur.com/28KLA0s.png

15th Jul 2017, 3:33 AM
PurePureMilk
1 Réponse
+ 7
This is probably because Code::Blocks run a lower version of the C++ compiler which has a non-overloaded version of .open() which requires the string literal stored inside a string variable to be converted to C-style strings (const char*) before accepting it as a legit parameter. Try including <cstring> header and do: outputfile.open(receiptName.c_str());
15th Jul 2017, 6:16 AM
Hatsy Rei
Hatsy Rei - avatar