Click here to Skip to main content
       

ATL / WTL / STL

 
Questionbetter version of strcpy() and printf() Pinmemberbkelly1315-Sep-12 11:02 
AnswerRe: better version of strcpy() and printf() PinmentorPaul Watt15-Sep-12 13:33 
bkelly13 wrote:
Are there any versions of ...cpy...() and ...printf...() that limit the count of
characters copied to the space found in the destination string.  
Without an ungracefull app crash?

 
Unfortunately, No. Strcpy and printf are two of the most common functions that hackers use to exploit programming errors to "hack" into a program. When using these functions you need to pay extra attention to the size of your memory buffers and the actions you are performing on them.
 
You may have better luck with the C++ Standard Library.
 
The std::string class will manage your memory buffers, copies and concatenations.
std::cout doesn't have the program crash issues that you are running into.
All of my software is powered by a single Watt.

GeneralRe: better version of strcpy() and printf() Pinmemberbkelly1315-Sep-12 16:34 
GeneralRe: better version of strcpy() and printf() PinmentorPaul Watt15-Sep-12 16:45 
GeneralRe: better version of strcpy() and printf() Pinmemberbkelly1315-Sep-12 17:23 
GeneralRe: better version of strcpy() and printf() Pinmemberpasztorpisti16-Sep-12 7:54 
GeneralRe: better version of strcpy() and printf() PinmvpRichard MacCutchan16-Sep-12 1:10 
AnswerRe: better version of strcpy() and printf() PinmemberRichard Andrew x6415-Sep-12 18:01 
AnswerRe: better version of strcpy() and printf() PinmvpRichard MacCutchan16-Sep-12 1:09 
AnswerRe: better version of strcpy() and printf() Pinmemberpasztorpisti16-Sep-12 2:37 
AnswerRe: better version of strcpy() and printf() PinmemberStephen Hewitt18-Sep-12 1:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 22 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid