View Single Post
  #2 (permalink)  
Old 05-16-2008, 07:46 AM
v0id's Avatar   
v0id v0id is offline
Super Moderator
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,414
Last Blog:
CherryPy(thon)
Rep Power: 27
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default Re: Row length changes?

In what way doesn't it work?

I've made an example. It shows how to re-allocate some already allocated space.
Code:
int row_size = 5;
int *row = (int *)malloc(sizeof(int) * row_size);

*(row+0) = 1;
*(row+1) = 4;
*(row+2) = 5;
*(row+3) = 2;
*(row+4) = 4;

row_size++;
row = (int *)realloc(row, sizeof(int) * row_size);

// After the re-allocation, we can now fill index five, too
*(row+5) = 6;
Reply With Quote