building an unsigned character string.

J

Justin

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.
 
J

Justin

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.
 
I

int2str

Justin said:
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
 
J

Jack Klein

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.
 
D

Default User

Justin said:
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
 
H

Howard

Justin said:
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"?)
 
J

Jim Langston

Justin said:
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 == " " )
MyString = MyString + '\0';
else
MyString = MyString + Input;
}
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 == " " )
MyString = '\0';
else
MyString = Input;
}
// Warning, not positive of value of i at this point, it should be strlen
though
MyString[i++] = '\0';
MyString[i++] = '\0';
MyString = '\0';
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top