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

Conversion from number to string or char* type

how to convert a number into word using cpp
Jul 24 '07 #1
6 1550
iWillLiveforever
136 100+
wait do you mean an int into a char.

if so check out atoi()
Jul 24 '07 #2
sicarie
4,677 Expert Mod 4TB
Next time, please read and follow the Posting Guidelines.
Jul 24 '07 #3
ilikepython
844 Expert 512MB
wait do you mean an int into a char.

if so check out atoi()
Do you mean itoa()? Look at "atoi", ascii (string) to integer", "itoa" integer to ascii (string).

You can also use a string stream:
Expand|Select|Wrap|Line Numbers
  1. #include <sstream>
  2.  
  3. int num = 65;
  4. string numstr;
  5.  
  6. stringstream ss;
  7. ss << num;
  8. ss >> numstr;
  9.  
  10. cout << numstr << endl;
  11.  
Jul 24 '07 #4
iWillLiveforever
136 100+
oops sorry I got confused between them I havent used them in a while.

besides i usually do sprintf with a buffer to convert the two but most people find that way harder.
Jul 25 '07 #5
iWillLiveforever
136 100+
Next time, please read and follow the Posting Guidelines.
To whom are you talking to niru132 or me?
Jul 25 '07 #6
sicarie
4,677 Expert Mod 4TB
I was speaking to the OP. Its not a big deal this time, but it would have been easy for the OP to put that into Google and get the answer, or even this site as I know we have answered this question before. And with larger questions (once again why its not incredibly important in this case) its nice to have the code the OP used, or the methodology of how they are going about it.

Edit:: I have changed the thread title to better describe the issue, and hopefully allow more people to either comment, or find an answer to a similar question (also in the Posting Guidelines ;)
Jul 25 '07 #7

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

Similar topics

30
by: Tim Johansson | last post by:
I'm new to C++, and tried to start making a script that will shuffle an array. Can someone please tell me what's wrong? #include <iostream.h> #include <string.h> int main () {...
16
by: frs | last post by:
See example below: Why does the output of 'a' work and the output of 'b' fails to compile? Is there a way to write class 'something' so that 'b' converts correctly by default? (include iostream,...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
8
by: Eric Lilja | last post by:
Hello, I have IPv4-numbers in the following format: "\\x0A\\x11\\x8C\\x01" Now I need each byte as an int. I wrote the following test program: #include <stdio.h> #include <stdlib.h> static...
31
by: Martin Jørgensen | last post by:
Hi, I've had a introductory C++ course in the spring and haven't programmed in C++ for a couple of months now (but I have been programmed in C since january). So I decided to do my conversion...
9
by: Notebooker | last post by:
Hello, I'm an intermediate noob reading-in data from ascii-file using an ifstream object. I have specified a c-style string buffer with size of type size_t and I am specifying to use this...
11
by: jyck91 | last post by:
// Base Conversion // Aim: This program is to convert an inputted number // from base M into base N. Display the converted // number in base N. #include <stdio.h> #include <stdlib.h>...
7
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are...
0
by: maheshmohta | last post by:
Background Often while remodeling legacy application, one of the important tasks for the architects is to have an optimum usage of storage capabilities of database. Most of the legacy applications...
9
by: jl_post | last post by:
Hi, A few months back I remember reading through C++ newsgroups trying to find a way to quickly convert a number to a C++ std::string. I often see code like: // Create a string that holds a...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.