c++ - Borland error that works in Microsoft: Couldn't find a match for 'ifstream::open' -


i want read in text file has name: abc.txt

the text file contains simple a, b, , c, each on own line.

when compile using microsoft compiler, compiles no problem @ , output expect (see below):

a b c (blank line here) 

here's borland compile line i'm using:

bcc32 -w -ebor.exe main.cpp

here's main.cpp file i'm using:

main.cpp

#include <iostream> #include <fstream> #include <string> void printout(const std::string &file);  int main(void) {   printout("abc.txt");   return 0; }  void printout(const std::string &file) {   std::ifstream words;   std::string   str;    words.open(file);    while(!words.eof())   {     std::getline(words, str);     std::cout << str << "\n";   }    words.close(); } 

the exact error i'm getting in borland follows:

error e2285 main.cpp 17: not find match 'ifstream::open(const std::string)' in function printout(const std::string &)

i'm getting warning, seems reason it's happening due error preventing 'file' being used:

warning w8057 main.cpp 26: parameter 'file' never used in function printout(const std::string &)

any appreciated, thank you.

before c++11, std::ifstream::open required const char *. use this.

words.open( file.c_str() ); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -