473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

building an unsigned character string.

i need to build the unsigned character string:
"PR0N\0Spam\0G1RLS\0Other\0Items\0\0\0"

from the signed character string:
"PR0N Spam G1RLS Other Items"

Tokeninzing the character string is not a problem. I can't solve my
concatenation problem. I've researched this topic extensively and I've
found nothing to help. Failure resulted when I used memcpy,_mbscat, and
various other methods. If anyone knows how to build a unsigned
character string from a signed character string and inserting a NULL
'\0)' between items I would greatly appreciate advice.

Jan 11 '06 #1
7 2488

Justin wrote:
Tokeninzing the character string is not a problem. I can't solve my
concatenation problem.


See here:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

Cheers,
Andre

Jan 11 '06 #2
You're an idiot, Andre. I don't need a lecture on how to post a
question. I need someone else's working code because the code that I
wrote does not do what I want and it's not a matter of fixing it. And
guess what guy, this is the place where people know how to answer
questions like mine! Incidentially, get a new name. Andre is a gay's
name.

Jan 11 '06 #3

Justin wrote:
You're an idiot, Andre.
Ok. What about that is related to the C++ Language?
I don't need a lecture on how to post a question.
Apparently you do. Because "write my code" is not a question. Not
including any quotes when replying is also not the proper way to post.
Neither is trolling.
I need someone else's working code because the code that I
wrote does not do what I want and it's not a matter of fixing it.
You said you used "memcpy" and it caused a "failure". If you post the
code (as the FAQ states) we can tell you why it's broken. But we're not
here to do your work for you.
And guess what guy, this is the place where people know how to answer
questions like mine!
Well then... ignore me ;)
Incidentially, get a new name. Andre is a gay's name.


Uhhmm, ok - I guess ;). Though please stay on topic (C++).

Cheers,
Andre

Jan 11 '06 #4
On 10 Jan 2006 16:59:44 -0800, "Justin" <jb******@gmail.com> wrote in
comp.lang.c++:
i need to build the unsigned character string:
"PR0N\0Spam\0G1RLS\0Other\0Items\0\0\0"

from the signed character string:
"PR0N Spam G1RLS Other Items"

Tokeninzing the character string is not a problem. I can't solve my
concatenation problem. I've researched this topic extensively and I've
found nothing to help. Failure resulted when I used memcpy,_mbscat, and
various other methods. If anyone knows how to build a unsigned
character string from a signed character string and inserting a NULL
'\0)' between items I would greatly appreciate advice.


If you can't get memcpy() to work, there is something wrong with the
way you used it. Post your code.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jan 11 '06 #5
Justin wrote:
You're an idiot, Andre. I don't need a lecture on how to post a
question.


Yes, you do. You don't the basics of how to post to usenet.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Jan 11 '06 #6

"Justin" <jb******@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
You're an idiot, Andre.
Personal attacks aren't going to encourage anyone to help you.
I don't need a lecture on how to post a question.
Apparently, you do.
I need someone else's working code because the code that I wrote does not
do what I want and it's not a matter of fixing it.
If your code is not working, then the best way to resolve the problem - at
least here - is to post it and let others tell you WHY it's not working.
The memcpy function works fine with 0s. The strcpy function, however, would
obviously cause problems.
And guess what guy, this is the place where people know how to answer
questions like mine!
Only if you pay attention to the FAQ, and follow the advice others are
giving you here.
Incidentially, get a new name. Andre is a gay's name.


"Incidentially"? You might get a spell checker.

Is there a list of names which are "gay"? And would having such a name make
you gay? And would being gay affect your ability to program, or to help
others program?

-Howard (wait... don't tell me... that's "gay" too, right? Maybe I should
use "Howie"?)

Jan 11 '06 #7
"Justin" <jb******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
i need to build the unsigned character string:
"PR0N\0Spam\0G1RLS\0Other\0Items\0\0\0"

from the signed character string:
"PR0N Spam G1RLS Other Items"

Tokeninzing the character string is not a problem. I can't solve my
concatenation problem. I've researched this topic extensively and I've
found nothing to help. Failure resulted when I used memcpy,_mbscat, and
various other methods. If anyone knows how to build a unsigned
character string from a signed character string and inserting a NULL
'\0)' between items I would greatly appreciate advice.


It all depends on what you mean by "string". Do you mean std::string or
c-style string? Either way, do it one character at a time.

I.E.

char Input[] = "PR0N Spam G1RLS Other Items";
std::string MyString;
for ( int i = 0; i < strlen( Input ); ++i )
{
if ( Input[i] == " " )
MyString = MyString + '\0';
else
MyString = MyString + Input[i];
}
MyString = MyString + '\0' + '\0' + '\0'; // This might need to be 3 lines

Do the same thing if your "string" is a char array.

char Input[] = "PR0N Spam G1RLS Other Items";
char MyString[100];
for ( int i = 0; i < strlen( Input ); ++i )
{
if ( Input[i] == " " )
MyString[i] = '\0';
else
MyString[i] = Input[i];
}
// Warning, not positive of value of i at this point, it should be strlen
though
MyString[i++] = '\0';
MyString[i++] = '\0';
MyString[i] = '\0';
Jan 12 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ian Gibbons | last post by:
Firstly what type is %x as I've not encountered it before? Now the problem: I'm trying to alter a host masking system for ircd so that it masks all but the isp name and location (if .uk.us etc..)....
19
by: Christopher Benson-Manica | last post by:
Given signed char str_a="Hello, world!\n"; unsigned char str_b="Hello, world!\n"; what is the difference, if any, between the following two statements? printf( "%s", str_a ); printf( "%s",...
8
by: archilleswaterland | last post by:
hello, is there any way that I can represent FF (11111111) as an unsigned char ? unsigned char ch; so if the user enters FF and i have printf("%c",ch); it should spit out FF
4
by: John Devereux | last post by:
Hi, I would like some advice on whether I should be using plain "chars" for strings. I have instead been using "unsigned char" in my code (for embedded systems). In general the strings contain...
42
by: sarathy | last post by:
Hi, I need clarification regarding signed characters in the C language. In C, char is 1 byte. So 1. Unsigned char - ASCII CHARACTER SET - EXTENDED CHARACTER SET
5
by: wolverine | last post by:
Hi I want to know how to use basic_string with unsigned short (I have mentioned below why i have to do this). Could any tell me some good references in this topic. I am new to creating a new...
30
by: Yevgen Muntyan | last post by:
Hey, Why is it legal to do union U {unsigned char u; int a;}; union U u; u.a = 1; u.u; I tried to find it in the standard, but I only found that
33
by: Michael B Allen | last post by:
Hello, Early on I decided that all text (what most people call "strings" ) in my code would be unsigned char *. The reasoning is that the elements of these arrays are decidedly not signed. In...
107
by: bmshivaraj | last post by:
Hi, Could any one tell me how to convert a unsigned long value into string (char *) ? In C++ there is a function _ultoa so wanted a similar one in C . Regards, Shivaraj
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.