Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC VC9.0 VC VC++
CString WriteString;
....
 
	WriteString.Format("%s.%d d",WriteString,NI);
 
At above WriteStringthe buffer too small warning is shown when executed any times because CStringtype is not enough to hold string of any size.
 
My goal is to get content ofWriteStringto write in to a file at end.
 
But it shows the warning when size of WriteStringreach to a limit. Is there any other way to write these strings to a file?or make the writeString be of unlimited size.
Posted 1-Apr-12 19:55pm
chaiein1.8K
Comments
swapnilKumbhar at 2-Apr-12 1:31am
   
Refer this.may help you to solve your query.
http://msdn.microsoft.com/ja-jp/library/ms928943.aspx
Resmi Anna at 2-Apr-12 1:53am
   
How much data is the WriteString holds. Actually there is no size limit for CString. Depends on system memory and process memory. Please post the exact warning message and line you are getting.
chaiein at 2-Apr-12 4:31am
   
solved problem as below solutions :) thank you :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

WriteString.AppendFormat("%du.",NI,CPianoCtrl::NoteUporDwn);
 
This also works.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In the Format(..) context,
try to use the string as the receiver only Smile | :) :
  CString cszComposed(_T("SomeValue"));
  ...
  CString cszTemp;
  cszTemp.Format(_T(".%d d"), NI);
  cszComposed += cszTemp;
  Permalink  
v2
Comments
chaiein at 2-Apr-12 4:27am
   
Thank you it works:)I have updated below solution 2 which can also works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,853
1 Sergey Alexandrovich Kryukov 7,107
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 2 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100