Search Results

Search found 2 results on 1 pages for 'bigbirdy'.

Page 1/1 | 1 

  • 2d array, using calloc in C

    - by BigBirdy
    Hi, I'm trying to create a 2D array of chars to storage lines of chars. For Example: lines[0]="Hello"; lines[1]="Your Back"; lines[2]="Bye"; Since lines has to be dynamically cause i don't know how many lines i need at first. Here is the code i have: int i; char **lines= (char**) calloc(size, sizeof(char*)); for ( i = 0; i < size; i++ ){ lines[i] = (char*) calloc(200, sizeof(char)); } for ( i = 0; i < size; i++ ){ free(lines[i]); } free(lines); I know that each line can't go over 200 chars. I keep getting errors like "error C2059: syntax error : 'for'" and such. Any ideas of what i did wrong?

    Read the article

  • An array of LPWSTR pointers, not working right.

    - by BigBirdy
    Declare: LPWSTR** lines= new LPWSTR*[totalLines]; then i set using: lines[totalLines]=&totalText; SetWindowText(totalChat,(LPWSTR)lines[totalLines]); totalLines++; Now I know totalText is right, cause if i SetWindowText using totalText it works fine. I need the text in totalLines too. I'm also doing: //accolating more memory. int orgSize=size; LPWSTR** tempArray; if (totalLines == size) { size *= 2; tempArray = new LPWSTR*[size]; memcpy(tempArray, lines,sizeof(LPWSTR)*orgSize); delete [] lines; lines = tempArray; } to allocate more memory when needed. My problem is that the lines is not getting the right data. It works for the first time around then it get corrupted. I thought at first i was overwriting but totalLines is increase. Hopefully this is enough information.

    Read the article

1