473,782 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert a char[] of integers to a string.

I can convert from a string to a char array (char[]) by using
string.ToCharAr ray() function. Now how do I convert it back?

The string looks like this: "000457". I've converted it to a char
array: char[] = {0, 0, 0, 4, 5, 7}. Now I need to convert it back to a
string.

Thanks in advance for your help.

Steve

Feb 26 '07 #1
2 2354
It's so simply you're going to want to kick yourself, it's also so simple
that it's going to get overlooked.

string mystring = new string(charArra y);

if you look at the overloaded constructor for the string class, you'll
notice that one of the parameters is a char array. This "should" work just
fine though I haven't toyed with it in a long time.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Steve Kershaw" <st***********@ yahoo.comwrote in message
news:11******** *************@h 3g2000cwc.googl egroups.com...
>I can convert from a string to a char array (char[]) by using
string.ToCharAr ray() function. Now how do I convert it back?

The string looks like this: "000457". I've converted it to a char
array: char[] = {0, 0, 0, 4, 5, 7}. Now I need to convert it back to a
string.

Thanks in advance for your help.

Steve

Feb 26 '07 #2
On Feb 26, 11:47 am, "Mark Fitzpatrick" <markf...@fitzm e.comwrote:
It's so simply you're going to want to kick yourself, it's also so simple
that it's going to get overlooked.

string mystring = new string(charArra y);

if you look at the overloaded constructor for the string class, you'll
notice that one of the parameters is a char array. This "should" work just
fine though I haven't toyed with it in a long time.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Steve Kershaw" <steve_kers...@ yahoo.comwrote in message

news:11******** *************@h 3g2000cwc.googl egroups.com...
I can convert from a string to a char array (char[]) by using
string.ToCharAr ray() function. Now how do I convert it back?
The string looks like this: "000457". I've converted it to a char
array: char[] = {0, 0, 0, 4, 5, 7}. Now I need to convert it back to a
string.
Thanks in advance for your help.
Steve- Hide quoted text -

- Show quoted text -
You are right! I did kick myself for overlooking the simple solution.
Thanks for your help!!!!

Steve

Feb 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1941
by: Markus Zeindl | last post by:
Hello, I want to write a simple encrypter, but I've got a problem: How can I convert characters into integers? I have got a string from the user, for example "Hi!". Now I get every character with a loop: <code> buffer = "" for i in range(len(message)):
7
4832
by: Chris Ritchey | last post by:
Hmmm I might scare people away from this one just by the title, or draw people in with a chalange :) I'm writting this program in c++, however I'm using char* instead of the string class, I am ordered by my instructor and she does have her reasons so I have to use char*. So there is alot of c in the code as well Anyways, I have a linked list of linked lists of a class we defined, I need to make all this into a char*, I know that I...
5
7066
by: Sam Smith | last post by:
Hi, is there a function or a "well-known" algorithm which converts a number of random length represented as an array of bytes to its binary format? For example: a 16 byte long array: "9567081354794432" should be converted to the seven bytes: 0x21FD35B5B095C0 Thanks in advance Sam
4
12178
by: Vijai Kalyan | last post by:
I wrote the following function as a curiosity: template<typename SourceType, typename DestinationType> DestinationType NumericCast(const SourceType& value) { std::wstringstream strbuf; strbuf << value << std::endl ; strbuf.flush(); DestinationType convalue; strbuf >> convalue;
16
10126
by: Dave | last post by:
Hi all, I have a 4 byte char array with the binary data for two 16-bit signed integers in it like this: Index 3 2 1 0 Data Bh Bl Ah Al Where Bh is the high byte of signed 16-bit integer B and so on.
24
1094
by: djozy | last post by:
Please, how can I convert selected item from dropdown list to integer? Thank you
20
3447
by: Niyazi | last post by:
Hi all, I have a integer number from 1 to 37000. And I want to create a report in excel that shows in 4 alphanumeric length. Example: I can write the cutomerID from 1 to 9999 as: 1 ----> 0001 2 ----> 0002
30
17398
by: ceeques | last post by:
Hi I am a novice in C. Could you guys help me solve this problem - I need to convert integer(and /short) to string without using sprintf (I dont have standard libray stdio.h). for instance:- int i =2; char ch 'A'
4
25069
by: meendar | last post by:
Hi, I am having a character pointer which contains ascii values. i just want to convert all these ascii values to respective characters and again store it in another character pointer. Anybody please help in c language. Thanks in Advance.
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.