Re: spelling error in man page of strncpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Nikos,

On Thu, Mar 10, 2011 at 3:42 PM, Nikos Vervelakis <vervelak@xxxxxxxxxx> wrote:
> Hello
> in the man page of strncpy is a simple implementation that dosn't work
> an error was found in the secont for loop.
>  it must be "for ( ; i <= n ; i++) dest[i] = '\0';" insteed of "for ( ; i <
> n ; i++) dest[i] = '\0';"
>        A simple implementation of strncpy() might be:

At a quick glance, I don't think this report is correct. Could you
please add more detail on a specific case where you think the
implementation is broken?

Thanks,

Michael
>            char*
>            strncpy(char *dest, const char *src, size_t n){
>                size_t i;
>
>                for (i = 0 ; i < n && src[i] != '\0' ; i++)
>                    dest[i] = src[i];
> --->          for ( ; i < n ; i++)
>                    dest[i] = '\0';
>
>                return dest;
>            }
>
> Thanks
> vervelak.
>



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux