Solved

Question on String manipulation

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
mixString challenge 36 137
method notes when mouse over in eclipse 5 96
zeroMAx challenge 20 135
sumHeights  challenge 17 83
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

751 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