473,385 Members | 1,311 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,385 software developers and data experts.

convert str variable to char*

problem in C++

-variable of type std::string called str

egl

std:string str; // declaration

str+ ""; // initialized to this.........nothing.

-we need to pass the value of this variable to a function which requires a variable of type char *.

egl

drawString(screen, font, o,o, str)


-the easiest thing to do is convert the str variable to a char * type because alot of code has been written in the main () using std::string str and alot of code has been written in the drawSrting (....) function using char * str.
-we are currently using dev- C++ compiler.

-i believe there must be a siple way to convert but cannot come up with a solution
Oct 15 '07 #1
2 2432
ashitpro
542 Expert 512MB
problem in C++

-variable of type std::string called str

egl

std:string str; // declaration

str+ ""; // initialized to this.........nothing.

-we need to pass the value of this variable to a function which requires a variable of type char *.

egl

drawString(screen, font, o,o, str)


-the easiest thing to do is convert the str variable to a char * type because alot of code has been written in the main () using std::string str and alot of code has been written in the drawSrting (....) function using char * str.
-we are currently using dev- C++ compiler.

-i believe there must be a siple way to convert but cannot come up with a solution
consider...
string temp;
You can convert it to char * using
temp.c_str();
Oct 15 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
std:string str; // declaration

str+ ""; // initialized to this.........nothing.
The string is already initialized by its cionstructor. You do not need to intialize it yourself. Besides, str+ "" does not change str anyway.
Oct 15 '07 #3

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

Similar topics

5
by: IamZadok | last post by:
Hi I was wondering if anyone knew how to convert a string or an integer into a Static Char. Thx
7
by: Golan | last post by:
Hi, I need to convert a Binary value to Decimal. I've been told that the value is an unsigned one. How can I do this? I use memcpy into an unsigned char variable, but when I print the value I got...
7
by: Bernardo | last post by:
Hi There is any easy way to convert a 1Char string to a char variable string str="A" char ch=str.. Thanks for your help
3
by: keith | last post by:
In managed C++, there is variable String *s. The variable got value from a C# assembly. Then I need to convert it into char *c in order to call an external function in a dll that accepts parameter...
3
by: David | last post by:
Hi, how to convert a char array(byte) to a string variable? byte buffer; string strTest; /*the blow codes all get type of 'buffer': System.Byte! strTest = buffer.ToString() strTest =...
5
by: sjsn | last post by:
Basic C++, just started this course in school... So I'm very limited. What I'm at doing is, below I have a variable named inputTemp, which is the product of a char, F = Fahrenheit, C = Celsius...
2
by: renu | last post by:
hello, I have one structure named CHAINPOINT,like CHAINPOINT { int x,y; byte dir } I am creating object of CHAINPOINT like CHAINPOINT* arrayPoint; arrayPoint = new
8
by: Polaris431 | last post by:
I have a buffer that holds characters. Four characters in a row represent an unsigned 32 bit value. I want to convert these characters to a 32 bit value. For example: char buffer; buffer =...
14
by: rtillmore | last post by:
Hello, I did a quick google search and nothing that was returned is quite what I am looking for. I have a 200 character hexadecimal string that I need to convert into a 100 character string. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.