2
First I created a struct vector. Next I created a pointer vector, in which each element of this vector points to each element of the struct vector.
Finally, I need to pass both (the struct vector and the pointer vector) as parameters of a function. I have tried some ways searching here on the site, but it gave error. I just don’t know how to do it.
Follows the code:
#include <stdio.h>
#include <string.h>
struct dados
{
int dia, mes, ano;
char nome_mes[50];
char remetente[100];
char destinatario[100];
};
void ordenar(struct dados *cartas, ***O QUE COLOCAR AQUI***, int n){
//DUVIDA NESSA FUNÇÃO
}
void main(){
int n, i;
char lixo[5];
scanf("%d\n", &n);
struct dados cartas[n], *ponteiros[n];
for(i = 0; i < n; i++){
ponteiros[i] = &cartas[i];
}
for(i = 0; i < n; i++){
scanf("%d de ", &cartas[i].dia);
scanf("%s", cartas[i].nome_mes);
scanf("%s", lixo);
scanf(" %d\n", &cartas[i].ano);
gets(cartas[i].remetente);
gets(cartas[i].destinatario);
}
//DÚVIDA AQUI !!!
ordenar(cartas, ponteiros, n);
}
How to do this?