Hi everyone;
I made a linked list with a class called Patient, but in the loop where I go through each element, the programme doesnot work correctly(it Halts). It doesnt generate any compiler errors, it stops working whenever the function is provoked.
The following is the code of the function to save all entries in a file:
Code:void save(Patient* pNDS)
{
FILE *fp; // Declare a pointer to a file structurepNDS=pHead;
fp = fopen("D:junk.txt", "w+");
pNDS=pHead;
while(pNDS)
{//Cheap try to save in file
// This opens a file called
//junk.dat for writing (and reading)
fprintf(fp, "%s\t",pNDS->m_Name);
fprintf(fp, "%d\t",pNDS->m_ID);
fprintf(fp, "%d\n",pNDS->m_DOB);
fprintf(fp, "%s\t",pNDS->m_Address);
fprintf(fp, "%s\t",pNDS->m_PreMed);
pNDS=pNDS->pNext;
}
fclose(fp);
}
If anyone can help or even comment, that would be great..............Thanks.