About Store Forum Documentation Contact



Post Reply 
Convert string to char*
Author Message
Dynad Offline
Member

Post: #16
RE: Convert string to char*
thnx smile

There is always evil somewhere, you just have to look for it properly.
02-06-2010 12:57 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Brainache Offline
Member

Post: #17
RE: Convert string to char*
Here's a couple functions I use for send Esenthel Str using Raknet

I dont like the packString iteration.. but it does work...

void packString(Str test, RakNet::BitStream *output)
{
char buffer[4096];
int i;
for (i=0;i<test.length(); i++)
{
buffer[i] = test[i];
}
buffer[i] = '\0';

stringCompressor->EncodeString(buffer, 256, output);
}


Str unpackString(RakNet::BitStream *input)
{
char buffer[256];
stringCompressor->DecodeString(buffer, 256, input);
//cout << buffer;
Str test = Str(buffer);
return test;
}
02-10-2010 04:11 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #18
RE: Convert string to char*
Yea this will work as well indeed

There is always evil somewhere, you just have to look for it properly.
02-10-2010 05:10 PM
Visit this user's website Find all posts by this user Quote this message in a reply
trouble Offline
Member

Post: #19
RE: Convert string to char*
I think I don't understand this correctly.
What I did was saving Str type in to string type.

I having problems with doing the opposite.

Str test = (CChar8*)mystring or Str test = (char*)mystring doesn't want to work.
What am I doing wrong?
02-06-2012 01:56 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #20
RE: Convert string to char*
isn't it supposed to be Str8 test in this case?
02-06-2012 02:57 AM
Find all posts by this user Quote this message in a reply
trouble Offline
Member

Post: #21
RE: Convert string to char*
yes, my current Str was converted to Str8 by
string mystring;
mystring=(Str8)test;

but now nothing seems to work ( cant do the opposite ). I m trying to do:
test=mystring;

I need to convert mystring in to Str type.

Code:
std::string pass=(Str8)password;
MD5 hashedPass(pass);
password= ??
(This post was last modified: 02-06-2012 03:46 PM by trouble.)
02-06-2012 03:43 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #22
RE: Convert string to char*
Str8 conv=(Str8)password;
std::string pass=conv();
?
02-06-2012 05:16 PM
Find all posts by this user Quote this message in a reply
trouble Offline
Member

Post: #23
RE: Convert string to char*
no not really, I got it like this now. Everything compiles
Code:
std::string pass=(Str8)(password)();
(Str8)password()=&md5(pass);

when I do that, operator= fails and password is beeing input one not the hash. How can I solve this?
02-06-2012 10:19 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #24
RE: Convert string to char*
assign the md5 return to a new value? and use that?

There is always evil somewhere, you just have to look for it properly.
02-06-2012 10:24 PM
Visit this user's website Find all posts by this user Quote this message in a reply
trouble Offline
Member

Post: #25
RE: Convert string to char*
same result using
Code:
std::string pass=(Str8)(password)();
std::string res=md5(pass);
(Str8)password()=&res;

md5 algorithm is from here:
http://www.zedwood.com/article/121/cpp-md5-function

SOLVED

I don't like solution but it works.

Code:
std::string pass=(Str8)(password)();
std::string x=md5(pass);
password=S;
    password+=&x[0];
(This post was last modified: 02-07-2012 02:00 AM by trouble.)
02-06-2012 10:33 PM
Find all posts by this user Quote this message in a reply
Post Reply