Thread: display pointer value problem

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    74

    display pointer value problem

    hi all,
    i've create a list of pointer array and i pass them into another dialogue, but how to show their value directly just having the pointer?
    thanks~

    Code:
    for(j=0;j<=10;j++){
    str[j] = new CString(details);
    
    
    Result result;
    
    result.buffer[j] = str[j];
    }
    // below is result dialogue code
    
    for(i=0;i<=j;i++){
    resultlistbox.AddString(buffer[j]);  //<------error
    }

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Dereference the pointer:
    Code:
    resultlistbox.AddString(*(buffer[j]));

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    74
    actually my code is :

    Code:
    
    for(j=0;j<=10;j++){
    
    if(data.getdata(i).Find(target)>=0){ 
    details = data.getdetails();
    str[j] = new CString(details);
    
    
    Result result;
    
    result.buffer[j] = str[j];
    }
    // below is result dialogue code
    
    for(i=0;i<=j;i++){
    resultlistbox.AddString(*(buffer[j]));  
    }
    but my result got only one data with mutilple row even the result should be different data, what's wrong with the code?
    thanks!
    Last edited by mr_empty; 12-31-2007 at 03:03 AM.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Your loop variable is i.
    shouldn't it be ?
    Code:
    for(i=0;i<=j;i++){
        resultlistbox.AddString(*(buffer[i]));  
    }
    Kurt

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    74
    yes thx, the problem is solved, but is that using new CString() will create dynamic memory that can be searched faster and avoid overflow? why my searching is still slow and overflow occur when i increase the searching to 200?

    thx!

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Using new CString shouldn't speed up searching or avoid overflow if I'm understanding what you're referring to. CString already uses dynamic memory allocation internally, so there's no need to dynamically allocate it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 04-04-2009, 03:45 AM
  2. Problem with function's pointer!
    By Tirania in forum C Programming
    Replies: 5
    Last Post: 11-28-2008, 04:50 AM
  3. printf output makes no sense. Is it a Pointer problem?
    By officedog in forum C Programming
    Replies: 3
    Last Post: 10-03-2008, 09:01 AM
  4. Problem referencing structure elements by pointer
    By trillianjedi in forum C Programming
    Replies: 19
    Last Post: 06-13-2008, 05:46 PM
  5. Ban pointers or references on classes?
    By Elysia in forum C++ Programming
    Replies: 89
    Last Post: 10-30-2007, 03:20 AM