Re: FindFirstFile, how much faster than FindNextFile?

From: Alexander Grigoriev (alegr_at_earthlink.net)
Date: 02/12/05


Date: Fri, 11 Feb 2005 20:36:01 -0800

Joe,

If you want to see really horrible, hair-raising code, open a recent CUJ
(January?) and check how the guy is creating XML request strings. I don't
have the copy in front of me, but IIRC, it's an article by some Neil Roodyn.

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:qahp015kbp6bd55aeb777t9uvh0hlveed4@4ax.com...
>
> Why are you using strcpy? This already suggests serious problems with the
> code. It is not
> Unicode-aware programming for one thing, and it implies you have a
> fixed-size buffer into
> which you are copying a string, which immediately suggests that you are
> begging for some
> serious bug to arise. if FileName were a CString, then a simple assignment
> would have
> worked.
>
> Hint: if you ever write strcpy or strcat, THINK REAL HARD ABOUT WHY YOU
> DID IT. The answer
> is usually that you made a fundamental coding error. I use strcpy and
> strcat so
> infrequently that I find it a surprise when I need to do so (actually, the
> most often use
> I make of strcpy, or to be precise, _tcscpy, is putting the font name
> into a LOGFONT
> structure). I can't recall the last time I wrote strcat. Use CString, or
> if you like the
> C++ standard library, the string type. There is rarely a need in modern
> MFC programming to
> use cpy or cat functions. So rare that I don't believe it is appropriate
> here.
>



Relevant Pages

  • Re: Undeclared identifier error in file "xlocnum"
    ... I had issues with strcat and strcpy in 1975, and nothing in the intervening 30 years has ... you have done something that includes the safe-string library; ... you should not be using sprintf any longer. ...
    (microsoft.public.vc.mfc)
  • Re: Undeclared identifier error in file "xlocnum"
    ... there is still a reason to use those crappy old functions. ... >your code is used on other platforms and by other compilers you will ... >>strcpy or strcat these days, it is better to adopt safe programming practices. ...
    (microsoft.public.vc.mfc)
  • Re: Difference between strcpy() and strcat()?
    ... Leor Zolman wrote in message news:> "strcpy is safer than strcat because it is easier to check programmatically ... > length of the source string. ... With strcat, on the other hand, you have to ...
    (comp.lang.c)
  • Re: Undeclared identifier error in file "xlocnum"
    ... there is still a reason to use those crappy old functions. ... >strcpy or strcat these days, it is better to adopt safe programming practices. ...
    (microsoft.public.vc.mfc)
  • Re: Difference between strcpy() and strcat()?
    ... There's more "stuff" to think about when using strcat; ... I would never dream of using it "in place of" strcpy; ... std::string in C++ and try to avoid str*() whenever possible, ...
    (comp.lang.c)

Loading