Hi!
When you have a series of 0-characters in a unsigned * char,
how can you then place these into a string, and vice versa; string
to unsigned * char. I only get them recogniced as zero-termination…
Any sugestions anyone??
-Arve
Hi!
When you have a series of 0-characters in a unsigned * char,
how can you then place these into a string, and vice versa; string
to unsigned * char. I only get them recogniced as zero-termination…
Any sugestions anyone??
-Arve
What exactly are you trying to do?
“Arve Slenes” <slenesa@oslo.geco-prakla.slb.com> wrote in message
news:3B27A44A.E7032ADA@oslo.geco-prakla.slb.com…
Hi!
When you have a series of 0-characters in a unsigned * char,
how can you then place these into a string, and vice versa; string
to unsigned * char. I only get them recogniced as zero-termination…Any sugestions anyone??
-Arve
“Arve Slenes” <slenesa@oslo.geco-prakla.slb.com> wrote in message
news:3B27A44A.E7032ADA@oslo.geco-prakla.slb.com…
Hi!
When you have a series of 0-characters in a unsigned * char,
how can you then place these into a string, and vice versa; string
to unsigned * char. I only get them recogniced as zero-termination…
If the “strings” contains multipe 0-characters it’s not a string anymore.
0-character is an end of string. Strings can’t have multiple ends
You are apparently not dealing with strings but rather with memory blocks.
Look at the memcpy and familly function.
unsigned char * doesn’t really mean pointer to string, it means pointer
to element of 8 bits.
Any sugestions anyone??
-Arve
You can’t do what you want to do with the normal str*90 C functions. In C++
you can use a container class or you design one for yourself in C starting
with something like
class string
{
size_t buffer_size;
size_t string_length;
char * data;
};
Then just add functions to do all of the things that you need to do to it.
I.E. strlen(), strcpy(), strcat(), strchr(), strstr(), etc.
–
Bill Caroselli - Sattel Global Networks
1-818-709-6201 ext 122
OK, it was late yesterday… Now it’s a new morning… Yes, I know
strings can’t have multiple ends…
I mean moving a buffer of bytes (unsigned * char) with a certain length
specified to a C++ style string (which indeed can contain zeros as
elements). I guess I just have to copy byte for byte to and from the
C++ style string?? Or are there other more cunning ways to do it??
Anyone??
I guess I could use memcpy, but… it is not propper C++ style.
And I should perhaps use Ustring too…
-Arve
Mario Charest wrote:
“Arve Slenes” <> slenesa@oslo.geco-prakla.slb.com> > wrote in message
news:> 3B27A44A.E7032ADA@oslo.geco-prakla.slb.com> …
Hi!When you have a series of 0-characters in a unsigned * char,
how can you then place these into a string, and vice versa; string
to unsigned * char. I only get them recogniced as zero-termination…
If the “strings” contains multipe 0-characters it’s not a string anymore.
0-character is an end of string. Strings can’t have multiple ends >You are apparently not dealing with strings but rather with memory blocks.
Look at the memcpy and familly function.unsigned char * doesn’t really mean pointer to string, it means pointer
to element of 8 bits.Any sugestions anyone??
-Arve
And this actually is a problem when I use message queues (
mq_something() ) …
Arve Slenes wrote:
OK, it was late yesterday… Now it’s a new morning… Yes, I know
strings can’t have multiple ends…I mean moving a buffer of bytes (unsigned * char) with a certain length
specified to a C++ style string (which indeed can contain zeros as
elements). I guess I just have to copy byte for byte to and from the
C++ style string?? Or are there other more cunning ways to do it??
Anyone??I guess I could use memcpy, but… it is not propper C++ style.
And I should perhaps use Ustring too…-Arve
Mario Charest wrote:
“Arve Slenes” <> slenesa@oslo.geco-prakla.slb.com> > wrote in message
news:> 3B27A44A.E7032ADA@oslo.geco-prakla.slb.com> …
Hi!When you have a series of 0-characters in a unsigned * char,
how can you then place these into a string, and vice versa; string
to unsigned * char. I only get them recogniced as zero-termination…
If the “strings” contains multipe 0-characters it’s not a string anymore.
0-character is an end of string. Strings can’t have multiple ends >You are apparently not dealing with strings but rather with memory blocks.
Look at the memcpy and familly function.unsigned char * doesn’t really mean pointer to string, it means pointer
to element of 8 bits.Any sugestions anyone??
-Arve