Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C is not a low level language Date: Mon, 25 Feb 2019 01:55:19 -0800 Organization: None to speak of Lines: 36 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="d7a76040ef7e877133de8f8312ada9dc"; logging-data="24990"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IrmLjS79799Y/G6K/Sce9" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:bnPQWU4FIDEFpU0r8EOXhM9TJVQ= sha1:IndhWC5BRUglgepYLoMCJY/IbCg= Xref: csiph.com comp.lang.c:141293 "R.Wieser" writes: >> No, strncpy is designed to work with a specific (and, in >> recent history, rare) data structure, namely a fixed-length >> character array > > Yes, that is the, very old, description/explanation to it. Its /desiged > to/ (according to the description) to work on fixed-length strings /that are > not necessarily zero-terminated/. So you agree? > Q1: When was the last time you used it for such strings / for that purpose ? I'm not sure that I ever have. > Q2: would that not mean that /you/ would need to append a string terminator > (even just to be able to "printf" it) ? Of course I'd need to ensure that the target is null-terminated if I wanted to use its contents *as a string*. In practice, I'd just use something other than strncpy. > And to be blunt about it, for that case you would not even need a "strncpy", > as just copying the whole block of memory the string is in (to a block of > empty memory one char larger ofcourse) would be sufficient. And faster! > > Besides, you yourself already have shown that you use that function > differently than its intended usage ... I don't know what you're referring to. I haven't said that I use strncpy at all. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */