I am developing a c program. I am using this struct:
main.h:
#define LONG_CADENA 22
#define NUM_CADENAS 5
#define formato "%22s%22s%22s%22s%22s\n"
#define indi_format "%22s"
typedef struct Agenda
{
char* nom[NUM_CADENAS];
struct Agenda* ant;
struct Agenda* sig;
} ag;
I have this function to show the object Agenda:
#include <stdio.h>
#include "main.h"
ag* mostrarAgenda(ag* act)
{
unsigned i = 0;
void* ini;
ini = act;
while (act++->sig) //ma1: Reescribir esta línea utilizando el bucle for
{
for (; i<NUM_CADENAS; i++)
{
printf(indi_format, act->nom[i]);
}
}
printf("\n");
getchar();
return ini;
}
I need change this function to sort the structs by one of the elements, for example by ag->nom[0]. But im starting with C, and I dont know how I could do it
Somebody could help me?