I am finalizing a phone book and the program compiles almost integer, except in the function with the ordering method for the names. In the following code snippet, the compiler detects an error when I try to play struct
to the temporary variables, which will make the change of position if necessary and the same error it indicates in all the excerpts in which I try to use the data of struct
. The error message says "expected primary expression before ['token." And it's the same message everywhere I try to access struct
Excerpt from function:
typedef struct agenda{
char nome[30];
int numero;
}agenda;
void ordenar(void)
{
agenda vet;
int aux=1000, i, j, k, retorno;
char *str, *str2, *straux;
arq = fopen("agenda.bin", "a+b");
for (i = 0; i < aux; i++)
{
str = agenda[i].nome;
for (j = i + 1; j < aux; j++)
{
str2 = agenda[j].nome;
if (strcmp(str, str2) > 0)
{
vet = agenda[i];
agenda[i] = agenda[j];
agenda[j] = vet;
}
}
}