Error

Im makeing a password keeper. Basically i want to use a users input, save it to a file. But i cant take the input ( cin ) and turn it into a string. and use that to save. heres my code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
	// Password Keeper
	ifstream store;
	store.open("storeinfo.txt");
	char storeword[50];
	store >> storeword;

	cout<<"Widget360 Password Keeper v 1.0 Beta"<<std::endl;
	cout<<std::endl;
	cout<<std::endl;
	cout<<"Your Current Passwords are:"<<std::endl;
	cout<<storeword<<endl;
	cout<<endl;

	string getpass;
	string store;
	
	cout<<"Enter A New Password:  ";
	getline(cin, getpass);
	stringstream(getpass) >> store;
	cout<<"Would you like to save:  " << store << "?";
	string ask;
	char ask;
	getline(cin, ask);
	if (ask == "yes") {
		ofstream file;
		file.open("storeinfo.txt");
		file << store;
		file.close();
	} else {
		cout<<"too bad...";
	}
	cin.get();
	return 0;
}


look for the bold line.
That's a redefinition error. You already declared store as an ifstream. Choose a different name? EDIT: Better yet, why do you even need the second store? You already have getpass...

Also, see lines 31 and 32. You'll probably find yourself with a similar problem there. :/

-Albatross
Last edited on
wow, im a....yeah.................
but wooo....!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
this is the first program i didnt have to completely rewrite to work.
i think from now on im gonna write down what im thinking instead of doing it all in my head..
thanks albatross.

thnx, widget360
Topic archived. No new replies allowed.