Solved

typecast

Posted on 2001-08-06
2
195 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
  • 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

Title # Comments Views Activity
C Language combined operators 28 114
C++ Class Serialization, Encapsulation and Formatted Output 8 78
Android development question 2 54
Finding Divisors 5 16
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

856 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