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

How do i convert a character array to string.

Hi All,

Can someone tell me how do we convert a character array to string.
I know the other way.

For eg:-
String strvar = "hello";
printf("%s",strvar.c_str());

regards,
Venkat

Aug 19 '05 #1
2 10661
> Hi All,

Can someone tell me how do we convert a character array to string.
I know the other way.

For eg:-
String strvar = "hello";
printf("%s",strvar.c_str());

I hope you meant, string(lowercase 's'). And what are you doing in the
first statement? Converting a array of chars to a string object.

char arr[] = "Hello";
std::string str(arr);
regards,
Venkat


Srini

Aug 19 '05 #2
Venkat wrote:
Hi All,

Can someone tell me how do we convert a character array to string.
I know the other way.

For eg:-
String strvar = "hello";
printf("%s",strvar.c_str());


I assume the "String" with the uppercase S is a typo, and you really
mean std::string. std::string has both a constructor and an assignment
operator that char* arguments.
std::string s("hello");

std::string s;

s = "hello";

You need to get a decent reference book that covers these things. This
is basic stuff.


Brian
Aug 19 '05 #3

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

Similar topics

4
by: David Lawson | last post by:
I know how to conver a string to an array of strings, but I need to convert an ascii string to an array of integers (really unsigned chars). Eg, $str ="ABC"; needs to convert to something...
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
15
by: Kueishiong Tu | last post by:
How do I convert a Byte array (unsigned char managed) to a char array(unmanaged) with wide character taken into account?
5
by: scottrm | last post by:
I have a asp.net web service built in c# which is accepting a string parameter from a vb6 client. The string parameter contains some xml. I am attempting to convert the string to a byte array using...
20
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 ---->...
6
by: Gary Wessle | last post by:
Hi I have char buffer = "jackson"; how can I get the same effect by string name = "jackson"; char buffer = name; //will not work I tried conat_cast<char*(name.c_str());
4
by: Jonathan Wood | last post by:
Does anyone know why the toBase argument in Convert.ToString() is limited to 2, 8, 10, or 16? It takes virtually the same code to support all base values from 2 to 36. And can anyone tell me if...
4
by: sagar | last post by:
Hi Guys.. I Wanted to convert an int to a string in C#...but i cannot use any built in functions.So, can any one tell me an algorithm or a program to do so....please is urgent....
19
by: est | last post by:
From python manual str( ) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with repr(object) is that...
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. ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.