Casting int to char* 
March 24th, 2007, 09:25 AM
| | | |
I need to change an integer into char* in cpp as i wanted to give a
name or label in the loop as ,
kris1,kris2,kris3,kris4,.... where the loop starts at
i=1 to ..
even the string "kris" should be a char* .please help me , | 
March 24th, 2007, 09:25 AM
| | | | re: Casting int to char*
* urskris123@gmail.com: Quote:
I need to change an integer into char* in cpp as i wanted to give a
name or label in the loop as ,
>
kris1,kris2,kris3,kris4,.... where the loop starts at
i=1 to ..
>
>
even the string "kris" should be a char* .please help me ,
| You mean you want to convert an integer to a decimal string representation.
In C++, use std::string.
See FAQ item 39.1, currently available at <url:
http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.1>.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? | 
March 24th, 2007, 09:45 AM
| | | | re: Casting int to char*
On Mar 24, 1:22 pm, "Alf P. Steinbach" <a...@start.nowrote: Quote:
* urskris...@gmail.com:
> Quote:
I need to change an integer into char* in cpp as i wanted to give a
name or label in the loop as ,
| > Quote:
kris1,kris2,kris3,kris4,.... where the loop starts at
i=1 to ..
| > Quote: |
even the string "kris" should be a char* .please help me ,
| >
You mean you want to convert an integer to a decimal string representation.
>
In C++, use std::string.
>
See FAQ item 39.1, currently available at <url:http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-...>.
>
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
| Thank you but i need that i should get the result in char* format .I
need to give the labels like i specified .Am new to the groups .Sorry | 
March 24th, 2007, 09:55 AM
| | | | re: Casting int to char*
* urskris123@gmail.com: Quote:
On Mar 24, 1:22 pm, "Alf P. Steinbach" <a...@start.nowrote: Quote:
>* urskris...@gmail.com:
>> Quote:
>>I need to change an integer into char* in cpp as i wanted to give a
>>name or label in the loop as ,
>> kris1,kris2,kris3,kris4,.... where the loop starts at
>>i=1 to ..
>>even the string "kris" should be a char* .please help me ,
| >You mean you want to convert an integer to a decimal string representation.
>>
>In C++, use std::string.
>>
>See FAQ item 39.1, currently available at <url:http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-...>.
| >
Thank you but i need that i should get the result in char* format .
| Most probably you don't.
What is it that you're trying to achieve?
Don't tell about how you're trying to achieve that, the char*-based
scheme you have in mind, don't tell about that but /what/ is the effect
you want? Quote: |
>I need to give the labels like i specified .Am new to the groups .Sorry
| Yes, you should not quote signatures. I've corrected that in this
follow-up.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? | 
March 24th, 2007, 09:55 AM
| | | | re: Casting int to char*
On 24 Mar, 08:35, urskris...@gmail.com wrote: Quote:
On Mar 24, 1:22 pm, "Alf P. Steinbach" <a...@start.nowrote:> Quote: Quote:
I need to change an integer into char* in cpp as i wanted to give a
name or label in the loop as ,
| | > Quote: Quote:
kris1,kris2,kris3,kris4,.... where the loop starts at
i=1 to ..
| | > Quote: Quote: |
even the string "kris" should be a char* .please help me ,
| | > Quote: |
You mean you want to convert an integer to a decimal string representation.
| >> Quote: |
See FAQ item 39.1, currently available at <url:http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-...>.
| >
Thank you but i need that i should get the result in char* format .I
need to give the labels like i specified .Am new to the groups .Sorry
| Please don't quote signatures. Thank you.
If you really need to end up with a C-style string, after you've
created a std::string following the FAQ Alf posted, use the c_str()
member function of std::string. Bear in mind that you shouldn't alter
the string via the raw char* and you shouldn't use the raw char* if
you make any subsequent changes to the std::string. But neither of
those should matter if you do all the assembling and altering in the
std::string first.
Why is it you need a char*? Are you interfacing with some third party
function that takes a char*? Or are you doing an exercise where the
requirement is to use C-style strings?
Gavin Deane | 
March 24th, 2007, 09:55 AM
| | | | re: Casting int to char*
On Mar 24, 1:48 pm, "Alf P. Steinbach" <a...@start.nowrote: Quote:
* urskris...@gmail.com:
> Quote: |
On Mar 24, 1:22 pm, "Alf P. Steinbach" <a...@start.nowrote: | > Quote: Quote:
>I need to change an integer into char* in cpp as i wanted to give a
>name or label in the loop as ,
> kris1,kris2,kris3,kris4,.... where the loop starts at
>i=1 to ..
>even the string "kris" should be a char* .please help me ,
You mean you want to convert an integer to a decimal string representation.
| | >> Quote: Quote: |
See FAQ item 39.1, currently available at <url:http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-...>.
| | > Quote: |
Thank you but i need that i should get the result in char* format .
| >
Most probably you don't.
>
What is it that you're trying to achieve?
>
Don't tell about how you're trying to achieve that, the char*-based
scheme you have in mind, don't tell about that but /what/ is the effect
you want?
> Quote: |
I need to give the labels like i specified .Am new to the groups .Sorry
| >
Yes, you should not quote signatures. I've corrected that in this
follow-up.
>
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
| I want to append a number for labels in the loop .i achieved it thank
you .I did by using istring lb1="kris" and then lb1+=i(0,1,2,...in for
loop ) and then converting it into char* by c_str().
Thank you | 
March 24th, 2007, 10:15 AM
| | | | re: Casting int to char*
<urskris123@gmail.comwrote in message
news:1174726404.152791.292090@y66g2000hsf.googlegr oups.com... Quote:
On Mar 24, 1:48 pm, "Alf P. Steinbach" <a...@start.nowrote: Quote:
>* urskris...@gmail.com:
>> Quote:
On Mar 24, 1:22 pm, "Alf P. Steinbach" <a...@start.nowrote:
>* urskris...@gmail.com:
| >> Quote:
>>I need to change an integer into char* in cpp as i wanted to give a
>>name or label in the loop as ,
>> kris1,kris2,kris3,kris4,.... where the loop starts at
>>i=1 to ..
>>even the string "kris" should be a char* .please help me ,
>You mean you want to convert an integer to a decimal string
>representation.
| >> Quote: |
>In C++, use std::string.
| >> Quote:
>See FAQ item 39.1, currently available at
><url:http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-...>.
| >> Quote: |
Thank you but i need that i should get the result in char* format .
| >>
>Most probably you don't.
>>
>What is it that you're trying to achieve?
>>
>Don't tell about how you're trying to achieve that, the char*-based
>scheme you have in mind, don't tell about that but /what/ is the effect
>you want?
>> Quote: |
>I need to give the labels like i specified .Am new to the groups .Sorry
| >>
>Yes, you should not quote signatures. I've corrected that in this
>follow-up.
| >
I want to append a number for labels in the loop .i achieved it thank
you .I did by using istring lb1="kris" and then lb1+=i(0,1,2,...in for
loop ) and then converting it into char* by c_str().
| Wow, and you have gmail? |  |
Similar Threads | | Thread | Thread Starter | Forum | Replies | Last Post | | casting int to char | Eric | answers | 11 | November 12th, 2006 12:05 AM | | int to *char | Nitin Manoharan | answers | 12 | July 19th, 2005 04:33 PM | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|