[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to copy char* data to CString data type?

Posted on 2002-06-16
5
Medium Priority
?
1,714 Views
Last Modified: 2013-11-20
Hi All,

How to copy char[200] data to CString ?

Thanks,
0
Comment
Question by:vgopalji
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Expert Comment

by:migel
ID: 7083090
Hi!
char sz[200] = "Hi!";
CString str;
str = sz;
or your char array contains zeros?
0
 
LVL 1

Expert Comment

by:joakimf
ID: 7083212
Or you can do it in the constuctor:
char sz[200] = "Hi!";
CString str ( sz );

Just one less line :)

/Joakim
0
 

Expert Comment

by:muneeb_baig
ID: 7087868
Or you can also use the Format method fo CString. that would help u, if u wanna concat other string too:
char sz[200] = "xyz";
CString str;
str.Format("%s", sz);//would copy the contents of sz to str

//or to concat other string
str.Format("Other String and my data = %s", str);
0
 
LVL 6

Accepted Solution

by:
snoegler earned 150 total points
ID: 7092031
>> str.Format("%s", sz);

IMHO this is pretty bloated (and slow) for this task.
"str = sz;" does the job much faster, as pointed out by migel.
0
 
LVL 6

Expert Comment

by:snoegler
ID: 7117072
Hm. You should've given the points to migel :)
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question