Hi GReaper. Researching through internet I was able to add a function to add a patience record to the list based on the structure I created. This is the code I have but is still in progress, just started yesterday, is incomplete and I should put on this several hours the next week, maybe I won't sleep. Please, if you noticed that the code I wrote until now is wrong, tell me:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>//not used yet but I guess I will use later
#include <conio.h>//not used yet but I guess I will use later
#define SIZE_PATIENCE 10//To put a number of records using the structure
typedef struct {//this is the structure
char name_patience[40];
char rage[40];
char gender[40];
char observations[1024];
char diagnosis[40];
int day;//This code is for date of birth in format dd/mm/yy
int month;//This code is for date of birth in format dd/mm/yy
int year;//This code is for date of birth in format dd/mm/yy
} tpatience;
tpatience *first, *last, *next;
void read_information(tpatience *p) {
printf("Name of the patience: ");
fgets(p->name_patience,SIZE_PATIENCE,stdin);
printf("Insert the rage of the patience: ");
fgets(p->rage,SIZE_PATIENCE,stdin);
printf("Insert the gender of the patience: ");
fgets(p->gender,SIZE_PATIENCE,stdin);
printf("Insert the observations about the patience: ");
fgets(p->observations,SIZE_PATIENCE,stdin);
printf("Insert the diagnosis of the patience: ");
fgets(p->diagnosis,SIZE_PATIENCE,stdin);
printf("Insert the date of birth (dd/mm/yy)");
scanf("%d%d%d", &m->day, &m->month, &m->year);//I'm not sure this is correct, I accept suggestions.
}
void add_patience() {
tpatience *new;
new=(tpatience*)malloc(sizeof(tpatience));
if(new=NULL) {
printf("There is not enough memory\n");
}
printf("Name of the patience: "); //this is a copy paste from the previous function
fgets(p->name_patience,SIZE_PATIENCE,stdin);
printf("Insert the rage of the patience: ");
fgets(p->rage,SIZE_PATIENCE,stdin);
printf("Insert the gender of the patience: ");
fgets(p->gender,SIZE_PATIENCE,stdin);
printf("Insert the observations about the patience: ");
fgets(p->observations,SIZE_PATIENCE,stdin);
printf("Insert the diagnosis of the patience: ");
fgets(p->diagnosis,SIZE_PATIENCE,stdin);
printf("Insert the date of birth (dd/mm/yy)");
scanf("%d%d%d", &p->day, &p->month, &p->year);//As I said previously, I don't know if this is correct. I accept suggestions.
new->next=NULL;
if(next==NULL) {
printf("First patience\n");
first=new;
last=new;
} else {
last->next=new;
last=new;
}
}
.
.
.
.
//To develop many other functions such as printing patiences, search patiences, ... I haven't still worked in that.
.
.
.
.
int main()//To be developed in the next week
{
return 0;
}
I only have the structure, a function to read the data and a function to add a patience to the list. There are several more functions to be developed in the future: printing the list, create a menu, search a patience, delete a patience, modify a patience, ...