assistance needed in selecting the appropriate variable?

I'm making a small password system (*very* low tech, any dipshit can crack it). So, the user inputs some random text in, but I don't know which variable to use for this. Oh, and it gets stored into a file.
Do I use a string? *I tried this, but it only stores one word.
int(now that would be a pathetic attempt)?
What variable type do I use?
Cheers to anyone who can help!
...
Cheers!
A string can store more than a single word, try posting the code you used.
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <fstream>
#include <cstdio>
#include <sstream>
#include <cstdlib>

using namespace std;

string username;
string password;
string secret;                              //What variable?

fstream data("data.txt");
fstream text("stuff.txt");

void explain()
{
    cout <<"\tCreate a username and password first. Note, when\n"
         <<"\ta new set is created, it replaces the old one.\n"
         <<"\t(still working on it!) and that this uses the stupidest\n"
         <<"\tform of security ever created. DO NOT STORE CONFIDENTIAL\n"
         <<"\tSTUFF because any baffoon can crack this system. Also, you\n"
         <<"\tcan't make a username including spaces, as the program glitches badly.\n"
         <<"\t--PS: you can only store text.--\n\n\n";
         return;
}
void create()
{
    cout <<"Username: ";
    cin >> username;
    data <<"USERNAME: " <<username;
    data << endl;
    cout <<endl;


    cout <<"Password: ";
    cin >> password;
    data <<"PASSWORD: " <<password;
    data << endl;
    cout <<endl;
    return;
}
void secrettext()
{
    cout<<"Enter your secret text: ";
    cin>> secret;                      //The variable gets stored
    text<< secret;                     //here...
}

int main(int nNumberofArgs, char* pszArgs[])
{

    explain();
    create();
    secrettext();

    system("PAUSE");
    return 0;

}


oh, and i would like to find a way to make c++ not overwrite a file's contents. so it would display the text according to the username and pass.
Last edited on
Topic archived. No new replies allowed.