Solved

typecast

Posted on 2001-08-06
2
196 Views
Last Modified: 2010-04-02
I am trying to convert a int into a CString and when i do that i get symbols.

This is what i am using

int labelid = 18548;
CString labelname = "holder";
labelname += " - ";
labelname += CString(labelid);

when doing this i do not append the number.
0
Comment
Question by:holiday1
[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
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 20 total points
ID: 6357150
>>labelname += CString(labelid);

That won't work - however, you could use the 'Format' member of CString:

CString num;

num.Format ( "%d", labelid);

labelname += num;

0
 
LVL 86

Expert Comment

by:jkr
ID: 6357159
Ooops, that one got accepted pretty quickly :o)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

756 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