Click here to Skip to main content
16,011,170 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Knowing when views switch/close Pin
Ravi Bhavnani14-Oct-02 11:41
professionalRavi Bhavnani14-Oct-02 11:41 
QuestionHow to compare CString and CArray? Pin
ooosawaddee314-Oct-02 7:51
ooosawaddee314-Oct-02 7:51 
AnswerRe: How to compare CString and CArray? Pin
Chris Losinger14-Oct-02 7:56
professionalChris Losinger14-Oct-02 7:56 
AnswerRe: How to compare CString and CArray? Pin
User 988514-Oct-02 7:57
User 988514-Oct-02 7:57 
GeneralSTL question Pin
User 988514-Oct-02 7:28
User 988514-Oct-02 7:28 
GeneralRe: STL question Pin
valikac14-Oct-02 7:42
valikac14-Oct-02 7:42 
GeneralRe: STL question Pin
User 988514-Oct-02 9:54
User 988514-Oct-02 9:54 
GeneralRe: STL question Pin
Joaquín M López Muñoz14-Oct-02 10:59
Joaquín M López Muñoz14-Oct-02 10:59 
You can eliminate double copying if having an std::vector instead of a std::string is OK with you. Of course, copying is still done when resizing the container (but this is unavoidable):
std::vector<char> v(1);
size_t extra_space=0;
int len=0;
do
{
  if(!extra_space){ 
    v.resize(v.size()+512);
    extra_space=511; // reserve one char for the terminating null
  }
  char * p=&v[0]+v.size()-extra_space-1;
  len= recv(socket, p, extra_space, 0);
  extra_space-=len;
}while (len > 0);
v[v.size()-extra_space-1]='0';


Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: STL question Pin
Anonymous14-Oct-02 11:26
Anonymous14-Oct-02 11:26 
GeneralRe: STL question Pin
Joaquín M López Muñoz14-Oct-02 11:35
Joaquín M López Muñoz14-Oct-02 11:35 
GeneralRe: STL question - Loki Pin
Neville Franks14-Oct-02 12:16
Neville Franks14-Oct-02 12:16 
GeneralRe: STL question - Loki Pin
Mike Nordell14-Oct-02 15:48
Mike Nordell14-Oct-02 15:48 
GeneralRe: STL question - Loki Pin
Neville Franks14-Oct-02 16:26
Neville Franks14-Oct-02 16:26 
GeneralRe: STL question - Loki Pin
Joaquín M López Muñoz14-Oct-02 20:07
Joaquín M López Muñoz14-Oct-02 20:07 
GeneralRe: STL question - Loki Pin
Neville Franks14-Oct-02 20:25
Neville Franks14-Oct-02 20:25 
GeneralRe: STL question - Loki Pin
Joaquín M López Muñoz14-Oct-02 20:02
Joaquín M López Muñoz14-Oct-02 20:02 
GeneralRe: STL question - Loki Pin
Neville Franks14-Oct-02 20:31
Neville Franks14-Oct-02 20:31 
GeneralThread question Pin
Anonymous14-Oct-02 7:22
Anonymous14-Oct-02 7:22 
GeneralRe: Thread question Pin
valikac14-Oct-02 7:44
valikac14-Oct-02 7:44 
GeneralRe: Thread question Pin
Anonymous14-Oct-02 7:59
Anonymous14-Oct-02 7:59 
GeneralRe: Thread question Pin
valikac14-Oct-02 8:16
valikac14-Oct-02 8:16 
GeneralRe: Thread question Pin
Anonymous14-Oct-02 8:54
Anonymous14-Oct-02 8:54 
GeneralRe: Thread question Pin
valikac14-Oct-02 11:59
valikac14-Oct-02 11:59 
GeneralRe: Thread question Pin
Neville Franks14-Oct-02 12:23
Neville Franks14-Oct-02 12:23 
GeneralRe: Thread question Pin
RobJones14-Oct-02 18:26
RobJones14-Oct-02 18:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.