First I created a struct vector. Next I have created a vector of pointers, in which each element of this vector points to each element of the struct vector.
Finally, I need to pass both the vector of structs and the vector of pointers as parameters of a function. I've tried some of the ways of searching here on the site, but it was an error. I just do not know how to do it.
Follow 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?