|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Nov 2005
Città: Mantova
Messaggi: 115
|
[c++] Problema file con wxWidgets
Ciao a tutti, ho un grosso problema con i file in wxWidgets...
In poche parole creo un file chiamato profiles.pfl (binario ovviamente, il formato l'ho inventato io) in cui ci salvo la seguente struttura: Codice:
typedef struct{
wxString username;
wxString password;
wxString confirmpassword;
wxString name;
wxString surname;
wxString homephone;
wxString workphone;
wxString otherphone;
wxString homeemail;
wxString workemail;
wxString otheremail;
//etc...
}profile;
Codice:
void LoginFrame::access(wxCommandEvent& event)
{
wxFFile infile;
bool accessflag=false;
if(infile.Open(wxT("data/profiles/profiles.pfl"),wxT("rb")))
{
profile currentProfile;
eventsregister->addString(CODE_MES,wxT("Accesso in corso...\n"));
infile.Read(¤tProfile,sizeof(profile));
while(!infile.Eof())
{
if((currentProfile.username).Cmp(profiletextctrl->GetValue())==0)
if((currentProfile.password).Cmp(passtextctrl->GetValue())==0)
accessflag=true;
infile.Read(¤tProfile,sizeof(profile));
}
if((currentProfile.username).Cmp(profiletextctrl->GetValue())==0)
if((currentProfile.password).Cmp(passtextctrl->GetValue())==0)
accessflag=true;
}
else
{
eventsregister->addString(CODE_ERR,wxT("Non posso aprire il profiles file\n"));
}
if(accessflag==true)
eventsregister->addString(CODE_OK,wxT("Accesso avvenuto con successo\n"));
else
eventsregister->addString(CODE_ERR,wxT("Nessun profilo trovato con l'username inserito\n"));
infile.Close();
}
Quale può essere il motivo secondo voi? Grazie Ultima modifica di Gino+89+ : 13-01-2008 alle 21:58. |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Mar 2006
Città: Bergamo
Messaggi: 2499
|
non puoi salvare su file una struttura del genere perchè non puoi discriminare la grandezza della struttura, quindi non riuscirai mai a rileggere correttamente il file.
questo perchè sizeof(profile) non ha una dimensione fissa. dei usare i soliti char stringa[dimensione]
__________________
ho concluso con: kvegeta, doctordb, Leland Gaunt.
|
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Nov 2005
Città: Mantova
Messaggi: 115
|
Ok grazie mille risolto!
(non ci avevo pensato) |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 11:19.











ho concluso con: kvegeta, doctordb, Leland Gaunt.








