Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Dynamically growing array of strings

Avatar of bbcac
bbcac asked on
25 Comments1 Solution2345 ViewsLast Modified:
I am having problem implementing this. I need to make an array of strings of a dynamic size. Each string is to be should be dynamically sized as well. You'll see in the code that i have choosen to try to make each string 88 chars long, but that was just an attemp to make it work.. Here is the code I've tried thus far

   char *lines[];
   int row_count = -1;
   int return_code;
   lines = (char **) malloc((row_count + 1) * 88 * sizeof(char)); /** INITIATE THE SIZE: Doesn't work right now ***/  

   /** Runs a database query that works fine here ***/
   while (RESULTS_REMAIN())
         /** BIND RESULTS TO VARIABLES: Working ***/
        while (ROWS_REMAIN())
                row_count += 1;
                line = realloc((row_count + 1) * 88 * sizeof(char));   /*each line will be 88 chars long  increase the number of lines by 1 and reallocate*/
                sprintf (royal_flush[row_count] , "    %-20s$%-23s%s",pok_prg_date, prize, city);

Avatar of bpmurray
bpmurrayFlag of Ireland image

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

This problem has been solved!
Unlock 1 Answer and 25 Comments.
See Answers