i hace a class in c++ bcw

class Student {
public:

private:
unsigned int sIdNum;
char sSurname[20];
char sFirstname[20];
char mathid[10];
              };//Student

i need a function that fills a Student type dynamic array from a bin file called binfile1.dta the array starts with size[30]. And then do the same for another file binfile2.dta to fill a dynamic array student type char mathid[10] the array starts with size[5].when an array wants more memory it must renew it self and ask more space.

can anybody help me ?

the binfile1.dta has data for sIdNum,sSurname,sFirstname
the binfile2.dta has data for mathid (math id is like XX000 XX001 etc in lines )

>can anybody help me ?
If by "help" you mean "write it for me", no. Nobody will help you. If you mean help in the more traditional sense of you do the majority of the work and we give you hints and tips, and suggest ways to improve your solution, yes. We'll be happy to help. But as it is, you don't have any code and haven't told us how you plan to write this function, so there's nothing to help with.

>>mathid[10] the array starts with size[5].when an array wants more memory it must renew it self and ask more space.

You can't dynamically expand the array size when it is statically allocated like you posted in the class. You will have to make mathid a pointer if you want to change its size at runtime.

Or better yet, since this is a c++ program using std::string instead of character arrays. The string class will do all the messary memory allocations for you, simplifying your whole program.

If that file contains variable length strings then you can not read it with just one read statement. You will have to devise a more complex algorithm to read the file. Exactly what algorithm depends on the file's contents, that is, how was that file written.

Be a part of the DaniWeb community

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