Re: C (functional programming) VS C++ (object oriented programming)




"Richard Weeks" <rweeks@xxxxxxxxxx> wrote in message news:hzSMi.2983$Nz6.1304@xxxxxxxxxxxx
Charlie Gordon wrote:

This newsgroup is read by a lot of programmers with varying degrees of skill. The more become aware of strncpy's woes, the less likely they will be producing buggy code using it.


For the edification a programmer (myself) with varying degrees of skill, what exactly are strncpy's "woes?"

/*
Evil, buggy code. Don't do this at home kids.
*/

char buff[32];

strncpy(buff, argv[1], 32);
printf("Your string was %s\n", buff);

/*
This is just as bad in its way, but not an error
*/
char buff[1024];

char *bottleneck = "a string in an inner loop";

strncpy(buff, bottleneck, 1023);
buff[1023] = 0;

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm


.



Relevant Pages

  • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
    ... Mr Nilges, PLEASE STOP BEING SO IGNORANT OF COMMON COURTESY, ... > It is jejune to get into debates about skill. ... > what the highlevel administrator or ordinary programmer thinks it is. ... the "fellows on this ng who yawp about obscure details of their favorite ...
    (comp.programming)
  • Re: C#, .NET, VB.NET, Vista, etc. So What is the Point?
    ... which you have the greatest mastery, ... Nowhere have I or anyone else discounted the skill of the ... overlap where a highly experienced and skilled programmer with old tools can ... run rings around a poorly skilled programmer with new tools is irrelevant. ...
    (borland.public.delphi.non-technical)
  • Re: Longest Prefix Match
    ... Owens ... The most important skill a programmer can have is the ability to read. ...
    (perl.beginners)
  • Re: Good books in computer science?
    ... This will improve your skill more ... "Practice makes perfect" only ... Without some level of understanding and creativity, ... to be a good programmer. ...
    (comp.lang.python)
  • Re: Difference between system() and exec() and ``
    ... can have is the ability to LISTEN. ... important skill. ...
    (perl.beginners)