Solved

Question on String manipulation

Posted on 1998-11-07
1
167 Views
Last Modified: 2013-11-20
Hi,
     I'll illustrate my problem with a program segment.
---------------
int total=100;
CString str = "There are altogether ", str2;

//my intention is to combine the string which will appear
//like this: "There are altogether 100 cats!"
str2 = str + total + " cats!"; // this is improper!
MessageBox(str2);
--------------------------------
My question is how can I combine the whole thing above to have a message which says "There are altogether 100 cats!"?

For your informations, I'm writing my programs using MSVC 5.0, a dialog-based program and working on win98 platform.

Any help offered is very much appreciated!
0
Comment
Question by:justinng
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 20 total points
ID: 1324328
Replace
str2 = str + total + " cats!";
with
str2.Format("%s%d%s", str, total, " cats!");
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Need Help INsttalling wget on Mavericks OS X 3 81
fizzArray  challenge 1 47
has77  challenge 9 67
EvenOdd challenge 10 83
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now