strint <--> octect problem



Hi,

I've a problem with strings: I have to cast them to octect sequence and
throw the obtained sequence; at the end I re-cast to string to view the
output.
I noticed that with some kind of strings all works really fine, with some
other (longer or with a lot of white spaces strings) the software gives an
error of segmentation fault and the output isn't correct.
Why does this happen?
I believe the octect thowing part is correct because of the success with lot
of input, so the error could be in the casting...

My code is something like that:


  char* message ="Bla bla bla 123456789012XXX";
  char* msgstring;
  DispatcherDataQueue_mem * msg;     /* Sequence of octet */

  //Insert the strings in the octet sequences
   msg = DispatcherDataQueue_mem__alloc();
   msg->_length = strlen(message)+1;
   msg->_maximum = msg->_length;

   msg->_buffer = CORBA_sequence_CORBA_octet_allocbuf(msg->_length);
   for (i=0; i<msg->_length ; i++)
	   msg->_buffer[i] = (CORBA_octet) message[i];

   printf("The string read is %s.\n",(CORBA_char *)msg->_buffer);

	...<snip>...

	// WHEN I RECEIVE THE OCTECT BACK, I OUTPUT IN THIS WAY:
    printf("The message read length is %i\n", msg->_length);
    printf("The message read is %s.\n",(char*)msg->_buffer);
    msg->_release=CORBA_TRUE;
    CORBA_free(msg3);


Where is my horrible error??

Thanks everybody!
Samuele




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]