Solved

Question on String manipulation

Posted on 1998-11-07
1
205 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pressing cancel button with C# UI Automation 3 80
isEverywhere  challenge 19 82
Unix Command -- Challenging  question 7 95
Work with App store 7 67
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…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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