c++ - Error with fstream library -


i want open file in writing , put in variable there error :

include/filestream/filestream.cpp: in function 'void log(std::__cxx11::string)': include/filestream/filestream.cpp:26:5: error: request member 'close' in 'log', of non-class type 'void(std::__cxx11::string) {aka void(std::__cxx11::basic_string<char>)}'  log.close;      ^ include/filestream/filestream.cpp: in function 'void firstname_read(bool)': include/filestream/filestream.cpp:36:18: error: return-statement value, in function returning 'void' [-fpermissive]            return firstname;                   ^ include/filestream/filestream.cpp:42:18: error: return-statement value, in function returning 'void' [-fpermissive]            return firstname; 

and there file making trouble :

#include "filestream.h" void log(string argument) { logfile.open ("log.txt", fstream::out | fstream::app);  logfile << argument;  log.close; }  void firstname_read (bool boyorgirl) {  if (boyorgirl == true)      {           firstname.open("name/firstname_male.txt", fstream::in);            firstname.close;           return firstname;      } else      {           firstname.open("name/firstname_female.txt", fstream::in);           firstname.close;           return firstname;       } } 

thank you... if want file have project hosted on github :

https://github.com/calmunicorn/virtualsociety

in function log, file named logfile. try log.close. confuses compiler; can't close function ! use logfile.close().


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -