reading from file
hi,
I save a string value to a file, Now I want use this value again, but null return
save function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int save_pass(void)
{
/* function variables */
FILE *fp ;
int i ;
/* function process*/
fp = fopen("pass", "wb");
if(!fp)
{
return 1;
}
if(&newPassword)
{
fwrite(&newPassword, sizeof(string), 1, fp);
}
return 0;
}
|
comparing two strings
1 2 3 4 5 6
|
if (password == newPassword){
cout << "corect";
}
else {
cout << "Invalid";
}
|
load function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
int load_pass(void)
{
/* function variables */
FILE *fp ;
/* function process*/
fp = fopen("pass", "rb");
if(!fp)
{
return 1;
}
fread(&newPassword, sizeof(string), 1, fp);
if(feof (fp))
{
return 0;
}
}
|
Last edited on
Topic archived. No new replies allowed.