Original Post
//Written in C not C++
#include <stdio.h>
#include <stdlib.h>
struct StudentInfo{
char* name;
unsigned int roll;
};
typedef struct StudentInfo StdInfo;
int main(int argc, char** argv){
StdInfo* students;
unsigned int size = 3, i=0;
unsigned short int s = 1;
students = malloc( size*sizeof(StdInfo) );
do{
printf("Enter name of Student %d :\t", i);
scanf("%s", &(students.name));
printf("Enter Roll of Student %d :\t", i);
scanf("%d", &(students.roll));
printf("\n\nEnter another ? (1/0):\t");
scanf("%d", &s);
if(s == 1){
size *= 2;
students = realloc( students, size*sizeof(StdInfo) );
}
i++;
}while(s == 1);
free(students);
students = 0x0;
return 0;
}