home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,738 of 33,346   
   Marsh Ray to Fredrik Staxeng   
   Re: C API needs array of C strings, what   
   13 Dec 11 21:23:23   
   
   From: marsh@extendedsubset.com   
      
   On 12/13/2011 03:41 PM, Fredrik Staxeng wrote:   
   > WWSAPI represents an array of strings as (WCHAR **array, int count).   
   > I need to allocate temporary storage for the array, and for the converted   
   > strings.   
   >   
   >           array = new WCHAR *[count];   
   >           for(int i = 0; i<  n; ++i)   
   >                   array[i] = widen(get_input(i));   
   >   
   > What data structure should I use? I can use std::vector for the array,   
   > but what do i put in it?   
   WCHAR *   
      
   if (count <= 0) return;   
      
   vector  array;   
   array.reserve(count);   
   for (... i = 0; i < count; ++i)   
       array.push_back(...);   
      
   WwsapiFunction(&array[0]);   
      
   Don't forget to ensure that any storage allocated by your widen()   
   function gets cleaned up.   
      
   - Marsh   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca