Passwording problem (file streams and comparing)

Short statement of the problem: User can set password to protect the program from being run by someone else.
Password is then changed into multiple ints and saved to file using char table[x] containing all reasonable characters. Then, if password is set, program opens the file, decodes the ints back to characters and sets it to char passwordset[x] and asks the user to enter password (cin>>password).
Then uses strcmp(password,passwordset) to check whether or not they are same. Still it doesn't work.
I cout'ed passwordset to compare it with input password just for debugging and it returns 'noname' (example password) as well as character printed out as space (' '), but obviously being something else. What is the explanation of this problem and does anyone have any solution?
Thanks in advance :)

---------------------------------------------------------------------------------------------------
In addition, if it's of any help, i used pwfileout<<z<<' '; to save the file and reading file is stopped with do{...}while(pwfilein.eof()==0);.
Last edited on
Can you paste your code up or? If so put the code inside [code ][/code ] tags as i only found out the other night ;) - Take away the space inside those tags heh
I am afraid the code is too long to post it, still this is an extract concerning password function:
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
char table[x],//characters table
password[12], passwordset[12];
unsigned int passer, z, i, paso2, paso1, asend;
ifstream psin;
ofstream psout;
psin.open("pass.dat");
z=0;
while(psin.eof()==0)
{
psin>>passer;
asend=passer%1000; 
passer/=1000; 
passwordset[z]=table[asend-passer]; 
z++;
}
psin.close();
do
{
cin>>password;
}
while(strcmp(password,passwordset)!=0);
...
psout.open("pass.dat");
cin>>password;
z=0;
do
{
for(i=200;i<330;i++)
{
if(password[z]==table[i])
{
paso2=i;
}
}
paso1=rand()%500+100;
psout<<paso1<<paso1+paso2<<' ';
z++;
}
while(isgraph(password[z]));
psout.close();
I solved this problem myself after spending some time on it... I changed strcmp to simply compare single characters in a loop that is broken with !isgraph.
Sorry for taking your time before trying hard to solve problem myself.
Topic archived. No new replies allowed.