#include<stdio.h>
#include <string.h>
void main()
{
FILE *f = fopen("F:\\hongphat.txt","wb+");
char *password = "password";
int l = strlen(password);
fwrite(&l, sizeof(int), 1, f);
fwrite(&password, 1, strlen(password), f);
fclose(f);
FILE *g = fopen("f:\\hongphat.txt", "rb+");
char *passwordsame = new char[250];
int length;
fread(&length, sizeof(int), 1, g);
fread(passwordsame, length, 1, g);
int k = strlen(passwordsame);
fclose(g);
delete[]passwordsame;
}
i code this example to make a password for a file, but when i did that, i see that k is not equal to length ( length = 8), can anyone show my mistake
Aucun commentaire:
Enregistrer un commentaire