By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,102 Members | 1,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,102 IT Pros & Developers. It's quick & easy.

How to convert string to const unsigned char* ?

yabansu
P: 14
Hi,

I just want to know if there is a way of converting a string variable into a const unsigned char pointer. Alternatively, I expect a blabla() function as the following:

string str = "Hello";
const unsigned char* ptr = blabla(str);

Thanks...
yabansu
Dec 27 '06 #1
Share this Question
Share on Google+
2 Replies


Banfa
Expert Mod 5K+
P: 8,916
Expand|Select|Wrap|Line Numbers
  1. string str = "Hello";
  2. (const unsigned char *)str.c_str();
  3.  
But note it this pointer will become invalid the next time str is altered.
Jan 4 '07 #2

P: 98
thanks alot man, by job was probably saved by that reply ^_^
Jan 15 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.