troubleshooting Question

problem storing struct into array

Avatar of EddieH
EddieH asked on
11 Comments2 Solutions386 ViewsLast Modified:
I need to read data from a file into an in-memory array but i'm unsure how to do it. The problem is i don't know how big the array is going to be. I store all the data into a structure as follows:

struct recData
   char *surname;
   char *firstname;
   int age;

i succesfully tokenize the data into the required fields of my structure. But i am having problems storing them into my array.
I have a loop which goes through each line of the file and takes what i need.

I also am having problems mallocing the array, as i am unsure how something like that would be done as i have no idea how big my array is going to be.

Thanks for any help.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros