I have to write a function that reads from the keyboard a structure type variable and a function that displays a structure type variable. Subsequently, I have to use these functions to read and display a n number of elements of the structure. That's what I managed to write, but it does not look very correct and logical. I'd be very happy to help. Here's my code :
#include <stdio.h>
struct data{
int d, m, y;
}dt;
void readData(struct data element){
printf("\nData format dd-mm-yyyy : ");
scanf("%d %d %d", &element.d,&element.m,&element.y);
}
void read(struct data element,int n){
for(int i = 0; i < n; i++){
readData(element);
}
}
void display(struct data element){
printf("\n %d.%d.%d\n",element.d,element.m,element.y);
}
void displayN(struct data element, int n){
for(int i = 0; i < n; i++){
display(element);
}
}
int main() {
struct data dd1;
read(dd1,3);
displayN(dd1,3);
return 0;
}