Click here to Skip to main content
15,914,016 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Check if file is open Pin
Toby Opferman22-Jun-05 17:08
Toby Opferman22-Jun-05 17:08 
GeneralRe: Check if file is open Pin
Blake Miller22-Jun-05 12:26
Blake Miller22-Jun-05 12:26 
Generalprocess monitoring Pin
3loka22-Jun-05 7:09
3loka22-Jun-05 7:09 
GeneralRe: process monitoring Pin
Chris Losinger22-Jun-05 7:38
professionalChris Losinger22-Jun-05 7:38 
GeneralRe: process monitoring Pin
3loka22-Jun-05 10:28
3loka22-Jun-05 10:28 
GeneralYet another problem with LPCTSTR Pin
tomek1822-Jun-05 6:04
tomek1822-Jun-05 6:04 
GeneralRe: Yet another problem with LPCTSTR Pin
James R. Twine22-Jun-05 6:43
James R. Twine22-Jun-05 6:43 
GeneralRe: Yet another problem with LPCTSTR Pin
Bob Stanneveld22-Jun-05 6:56
Bob Stanneveld22-Jun-05 6:56 
James R. Twine wrote:
First, I would recommend that you stop using _sntprintf for doing a simple string copy. Use _tcsncpy, that is what it exists for.

It's recommended that someone should stop using all the unsafe functions from the C libraries and start using the C++ library! I was also using C functions for formatting strings and such, but found that using the C++ stringstreams have more flexibility and are more elegant and fool proof than their C equivalants.

A better code example would be:
// use the C++ STL
void CChildView::SortData(LPCTSTR pszData){    
    std::string sData(pszData);              
    DisplayData( sData.c_str() );

    // using string streams
    /*
    std::stringstream sDataStream;
    sDataStream << pszData;
    DisplayData( sDataStream.str().c_str() );
    */

    // using MFC's CString
    /*
    CString sData( pszData );
    DisplayData( sData.GetBuffer() );
    */
}


Utilizing the STL is better if performance is not a big issue, since it is less error prone that using straight C.

Behind every great black man...
            ... is the police. - Conspiracy brother


Blog[^]
GeneralRe: Yet another problem with LPCTSTR Pin
Blake Miller22-Jun-05 7:29
Blake Miller22-Jun-05 7:29 
GeneralRe: Yet another problem with LPCTSTR Pin
Bob Stanneveld22-Jun-05 8:43
Bob Stanneveld22-Jun-05 8:43 
GeneralRe: Yet another problem with LPCTSTR Pin
Toby Opferman22-Jun-05 9:17
Toby Opferman22-Jun-05 9:17 
GeneralRe: Yet another problem with LPCTSTR Pin
Bob Stanneveld22-Jun-05 20:27
Bob Stanneveld22-Jun-05 20:27 
GeneralRe: Yet another problem with LPCTSTR Pin
Toby Opferman23-Jun-05 10:10
Toby Opferman23-Jun-05 10:10 
GeneralOT Pin
Bob Stanneveld23-Jun-05 12:05
Bob Stanneveld23-Jun-05 12:05 
GeneralRe: OT Pin
Toby Opferman23-Jun-05 13:40
Toby Opferman23-Jun-05 13:40 
GeneralRe: OT Pin
Bob Stanneveld23-Jun-05 21:17
Bob Stanneveld23-Jun-05 21:17 
GeneralRe: OT Pin
Toby Opferman24-Jun-05 5:28
Toby Opferman24-Jun-05 5:28 
GeneralRe: OT Pin
Bob Stanneveld30-Jun-05 23:31
Bob Stanneveld30-Jun-05 23:31 
GeneralRe: OT Pin
Toby Opferman1-Jul-05 9:00
Toby Opferman1-Jul-05 9:00 
GeneralRe: Yet another problem with LPCTSTR Pin
JWood22-Jun-05 10:17
JWood22-Jun-05 10:17 
GeneralRe: Yet another problem with LPCTSTR Pin
Bob Stanneveld22-Jun-05 7:02
Bob Stanneveld22-Jun-05 7:02 
GeneralRe: Yet another problem with LPCTSTR Pin
tomek1823-Jun-05 2:06
tomek1823-Jun-05 2:06 
GeneralRe: Yet another problem with LPCTSTR Pin
Bob Stanneveld23-Jun-05 2:29
Bob Stanneveld23-Jun-05 2:29 
GeneralRe: Yet another problem with LPCTSTR Pin
tomek1823-Jun-05 4:01
tomek1823-Jun-05 4:01 
GeneralRe: Yet another problem with LPCTSTR Pin
Bob Stanneveld23-Jun-05 4:18
Bob Stanneveld23-Jun-05 4:18 

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

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