Sorry I got it wrong...
What I need to do is to store the date in the struct Tdata. The user will introduce the date in this format: 7-jun-1978.
Code:
typedef struct {
unsigned char dia;
unsigned char mes;
int any;
} TData;
char mesos[12][4]={"Gen","Feb","Mar","Abr","Mai","Jun","Jul","Ago","Set","Oct","Nov","Des"};
void printaMesos(void) {
int i;
for (i=0;i<12;i++) {
puts(mesos[i]);
}
}
int obtenirData( TData *d, char *text ) {
/*example obtenirData(&data, "7-Jul-1971");
analizes text and asigns the data in the fields of the structure Tdata. Returns -1 if error*/
return 0;
}
void donarData( Tdata *d, char *buffer) {
// writes to buffer a string that contains the date stored in d
// Does not return anything
}
void main() {
Tdata d;
char buffer[255];
char buffer1[255];
puts("Type an example string (7-Jul-1971)");
gets(buffer1);
if (obtenirData(&d, buffer1)==0) {
donarData(&d,buffer);
puts(buffer);
} else {
puts("error in format");
}
printaMesos();
}
Thanx again!!