Re: C (functional programming) VS C++ (object oriented programming)
- From: "Malcolm McLean" <regniztar@xxxxxxxxxxxxxx>
- Date: Wed, 3 Oct 2007 21:44:32 +0100
"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
.
- Follow-Ups:
- Re: C (functional programming) VS C++ (object oriented programming)
- From: Richard Heathfield
- Re: C (functional programming) VS C++ (object oriented programming)
- References:
- C (functional programming) VS C++ (object oriented programming)
- From: Joe Mayo
- Re: C (functional programming) VS C++ (object oriented programming)
- From: jacob navia
- Re: C (functional programming) VS C++ (object oriented programming)
- From: santosh
- Re: C (functional programming) VS C++ (object oriented programming)
- From: jacob navia
- Re: C (functional programming) VS C++ (object oriented programming)
- From: santosh
- Re: C (functional programming) VS C++ (object oriented programming)
- From: Richard Heathfield
- Re: C (functional programming) VS C++ (object oriented programming)
- From: Ben Pfaff
- Re: C (functional programming) VS C++ (object oriented programming)
- From: Richard Heathfield
- Re: C (functional programming) VS C++ (object oriented programming)
- From: Keith Thompson
- Re: C (functional programming) VS C++ (object oriented programming)
- From: Richard Heathfield
- Re: C (functional programming) VS C++ (object oriented programming)
- From: Charlie Gordon
- Re: C (functional programming) VS C++ (object oriented programming)
- From: Richard Weeks
- C (functional programming) VS C++ (object oriented programming)
- Prev by Date: Re: fwrite() misses writing a byte
- Next by Date: Re: About parsing the following if else condition
- Previous by thread: Re: C (functional programming) VS C++ (object oriented programming)
- Next by thread: Re: C (functional programming) VS C++ (object oriented programming)
- Index(es):
Relevant Pages
|