title: Read a binary file C programming
body: <p>I'm doing a program to manage a clinic, but I'm having a problem. I need to read a binary file with the information from the Doctors. The information is name, code and telephone. They are inserted by the user.</p>
  
  <p>How can I printf that info separately. For example:</p>
  
  <p>Name: John Cruz<br>
  Code: JC<br>
  Telephone: 90832324  </p>
  
  <p>I'm trying to use</p>
  
  <pre><code>typedef struct {
    char code[10];
    char name[100];
    int telephone;
  } DOCTOR;
  
  
  int newDoctor() {//This is the function that create the binary file
    DOCTOR d;
    FILE *fp;
    fp = fopen("Doctors.dat","wb");
  
    if(fp==NULL) {
      printf("Error!");
          return -1;
    }
  
    printf("Code\n");
    fflush(stdin);
    gets(d.code);
    printf("Name\n");
    gets(d.name);
    printf("Telephone\n");
    scanf("%d",&amp;d.telephone);
    fprintf(fp,"%s;%s;%d",d.code,d.name, d.telephone);
    fclose(fp);
  }
  
  //And to open
  FILE* fp;
  fp=fopen("Doctors.dat","rb");
  
  while(!EOF(fp)) {
    fgets(line, 100, fp);
    printf("%s",line);
  }
  </code></pre>
  
  <p>Just to see the line but it's not working, and how i can separate the info?</p>
  
  <p>Regards</p>