Well i have the following program

where i need to swap students(dynamically created structure array) .

Just cant seem to get the swap right.

Main problem's here :

struct student *stemp;
stemp=(struct student *)malloc(sizeof(student));

Other info :

where s[i] belongs to a dynamically created array student

struct student{
  char name[20];
  int m1,m2,m3;
s[i] is dynamically allocated memory:
struct student* s;
s=(struct student *)malloc(n*sizeof(student));

what i've also tried


Alright I've got it,the right was is:

struct student stemp;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.