OK, here's my sample code.
The problem is indicated with [PROBLEM] at the starting of the code line.

I'm getting a compilation error saying that:
706 C:\Users\user\Desktop\Project.cpp `reg_num' has not been declared
706 C:\Users\user\Desktop\Project.cpp request for member of non-aggregate type before ',' token

and its saying this for all my structure defined variables in that line.

pls help
Thanks

void search(char * record)
{
     
  //char check[50];
  //int search = 0;
  int found = 0;
 
               
   if((Clients=fopen("Clients.txt","r"))==NULL)
   {
   printf("THE FILE DATABASE IS EMPTY");
   }
   else
   {
[PROBLEM] while(fscanf(Clients,"%s %s %s %s %s %s %s %s %s",record.reg_num,record.name,record.dob,record.address,record.phone,record.occupation,record.allergy,record.l_treatment,record.l_appointment)==9 && Found==0)
     {
          if(strcmp(record,record.reg_num)==0)
          found=1;
     }
     if(found)
     {                                              
        printf("\n\nREGISTRATION #: %s",record.reg_num);
        printf("\n\nPATIENT'S NAME: %s",record.name);
        printf("\n\nDATE OF BIRTH [day/month/year]: %s",record.dob);
        printf("\n\nPATIENT'S ADDRESS: %s",record.address);
        printf("\n\nPATIENT'S PHONE #: %s",record.phone);                       
        printf("\n\nPATIENT'S OCCUPATION: %s",record.occupation); 
        printf("\n\nPATIENT'S ALLERGIES: %s",record.allergy);
        printf("\n\nLAST TREATMENT: %s",record.l_treatment); 
        printf("\n\nLAST APPOINTMENT: %s",record.l_appointment);  
     }
     else if(!found)
     {
      printf("\n\nTHERES NO SUCH RECORD");
     }    
     fclose(Clients); 
   }   
}

Where is reg_num declared?

Where is reg_num declared?

its declared at the top of the program in a structure called PATIENTS
as seen below

typedef struct
        {
            char name[50];
            char occupation[30];
            char allergy[20];
            char reg_num[10];
            char phone[15];
            char address[60];        
            char dob[15];
            char l_treatment[15];
            char treatment[25];
            char l_appointment[15];
            char n_appointment[15];
            char doc[20];
            float balance;      
        } PATIENT;

PATIENT record;

You are passing record in as a pointer. Don't you need record->xxx for all your fields instead of record.xxx ?

OP seems to have record being passed in as a char* . Shouldn't it pass in as struct PATIENT * record ?

commented: Exactly :) +8

OP seems to have record being passed in as a char* . Shouldn't it pass in as struct PATIENT * record ?

Good point. I missed that :icon_redface: I assumed it was the struct and didn't look close..

commented: No worries WaltP, I've had like 15+ of those in a row +2

You are passing record in as a pointer. Don't you need record->xxx for all your fields instead of record.xxx ?

WaltIP, could u please explain more about these two: record->xxx record.xxx What are the differences between them?

Doesn't you class have a textbook? The explanation should be in there in the section on pointers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.