fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7. class Fichero {
  8. private:
  9. char fichero[156];
  10. public:
  11. char* setFichero(char _fichero[156]) {
  12. strcpy(fichero, _fichero);
  13. }
  14. char* getFichero() {
  15. return fichero;
  16. }
  17.  
  18. } okia;
  19.  
  20. int main() {
  21.  
  22. char nameof[156];
  23. cin >> nameof;
  24.  
  25. okia.setFichero(nameof);
  26. string finalname = okia.getFichero();
  27. finalname.append("nop.desktop");
  28. cout << finalname;
  29. ofstream finalName(finalname,ios::app);
  30. return 0;
  31. }
  32.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘char* Fichero::setFichero(char*)’:
prog.cpp:13:9: warning: no return statement in function returning non-void [-Wreturn-type]
prog.cpp: In function ‘int main()’:
prog.cpp:29:46: error: no matching function for call to ‘std::basic_ofstream<char>::basic_ofstream(std::string&, const openmode&)’
prog.cpp:29:46: note: candidates are:
In file included from prog.cpp:4:0:
/usr/include/c++/4.7/fstream:629:7: note: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
/usr/include/c++/4.7/fstream:629:7: note:   no known conversion for argument 1 from ‘std::string {aka std::basic_string<char>}’ to ‘const char*’
/usr/include/c++/4.7/fstream:614:7: note: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
/usr/include/c++/4.7/fstream:614:7: note:   candidate expects 0 arguments, 2 provided
/usr/include/c++/4.7/fstream:588:11: note: std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)
/usr/include/c++/4.7/fstream:588:11: note:   candidate expects 1 argument, 2 provided
stdout
Standard output is empty