   linked list problems
  I'm having problems with a section of my code and I don't know why.. ThisAccount->Next should equal 0x00000000 but it doesn't, for some reason it equals 0x00006666 which makes my while loop run again ahich isn't what I want.fstream Account;Account.open("accounts.txt", ios::in);Account >> NumAccounts;for(unsigned int a = 0; a < NumAccounts; a++){AddAccount();}ACNTSTRUCT* ThisAccount = FirstAccount;while(ThisAccount != NULL){Account >> ThisAccount->AcntLoginName;Account >> ThisAccount->AcntPassword;Account >> ThisAccount->AcntSerial;AddString(CharToLPCWSTR(ThisAccount->AcntLoginName));ThisAccount = ThisAccount->Next;}Account.close();Here's my AddAccount function too incase the problem is in there.ACNTSTRUCT* AddAccount(){if(FirstAccount == NULL){FirstAccount = new ACNTSTRUCT;LastAccount = FirstAccount;LastAccount->Next = NULL;}else{LastAccount->Next = new ACNTSTRUCT;LastAccount = LastAccount->Next;LastAccount->Next = NULL;}strcpy(LastAccount->AcntLoginName,"NONE");strcpy(LastAccount->AcntPassword,"NONE");strcpy(LastAccount->AcntSerial,"NONE");return LastAccount;}
  where do ypu initializeFirstAccount???You should be setting it to NULL    newar the top of the first code block.You should never assume that unitialized varialbes/memory  have 0 in them.....;  From what I could test, it seemed to work OK:#include <fstream>using namespace std;struct ACNTSTRUCT {char AcntLoginName[256];char AcntPassword[256];char AcntSerial[256];ACNTSTRUCT *Next;};ACNTSTRUCT *FirstAccount = 0, *LastAccount = 0;ACNTSTRUCT* AddAccount(){if(FirstAccount == NULL){FirstAccount = new ACNTSTRUCT;LastAccount = FirstAccount;LastAccount->Next = NULL;}else{LastAccount->Next = new ACNTSTRUCT;LastAccount = LastAccount->Next;LastAccount->Next = NULL;}strcpy(LastAccount->AcntLoginName,"NONE");strcpy(LastAccount->AcntPassword,"NONE");strcpy(LastAccount->AcntSerial,"NONE");return LastAccount;}int main() {fstream Account;Account.open("account.txt", ios::in);unsigned int NumAccounts = 0;Account >> NumAccounts;for(unsigned int a = 0; a < NumAccounts; a++){AddAccount();}ACNTSTRUCT* ThisAccount = FirstAccount;while(ThisAccount != NULL){Account >> ThisAccount->AcntLoginName;Account >> ThisAccount->AcntPassword;Account >> ThisAccount->AcntSerial;ThisAccount = ThisAccount->Next;}Account.close();}Perhaps AddString is doing something funky?However, since you are using C++, why don't you simply use std::list? And while you're at it, you may as well make friends with std::string, it's a good friend to have.If you are doing this for learning purposes, then I suggest you look into proper usage of classes; it should make your life a little easier.jfl[Edited by - jflanglois on May 26, 2006 3:05:04 AM];  It works now after changin the array size of the login name password and serial to 256. I did just have them at what i thought would be the max for those. login and password were at 17 and serial was at 21   ;  Please, please, please (!) use std::string instead!jfl.   