I copied this function directly from my programing book, but it still does not work. The Line temp = tbp->entry[j]; gives me an error when compiling "cannot make assignment of this type"
here is all the relevent code (I think ) If anyone can tell me what I am doing wrong i would appreciate it.
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#define TEL_BOOK_SIZE 50
#define MAX_STRING_SIZE 81
struct tel_book_element
{char *name;
char *telNum;
};
typedef struct tel_book_element TelBookElement;
struct tel_book
{TelBookElement entry[TEL_BOOK_SIZE];
int n;
};
typedef struct tel_book TelBook;
...
void sort(TelBook *tbp)
{
int j,k, small;
TelBook temp;
for (j=0;j<tbp->n-1;j++)
{small = j;
for (k = j + 1; k < tbp->n;k++)
if (strcmp(tbp->entry[k].name, tbp->entry[small].name) < 0)
small = k;
temp = tbp->entry[j];
tbp->entry[j] = tbp->entry[small];
tbp->entry[small] = temp;
}
}