fstream - myFile undeclared identifier -


i following error when try solve file:

myfile undeclared identifier 

help appreciated! :) dont see problem in code.

#include "stdafx.h" #include <iostream> #include <fstream> #include <string> #include <windows.h>   int main() {     ofstream myfile;     std::string name;     std::string password;     std::cout << "enter name" << std::endl;     std::cin >> name;     std::cout << "enter password" << std::endl;     std::cin >> password;     std::string info = name + ":" + password;     myfile.open ("database.txt");     myfile << (info) << std::endl << ;     myfile.close();     sleep(10000); } 

you sould use : std::ofstream myfile declare myfile

or can add using namespace std; @ top of programm (outside main) , remove std::.

if want add text "database.txt", sould use :

myfile.open("database.txt", ios::app); 

something wrong :

myfile << (info) << std::endl << ; 

you sould'nt keep last <<

you may want return in main.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -