As I understand it, strncpy copies "index" number of characters of "buffer"
to "profile". Since "index" is less than length of "buffer", a null
character (\0) is not appended to the "profile".
I don't think length of "profile" enters into equation at all (i.e. you
could corrupt unallocated storage if not careful with your "index"
variable).

Elvis

Celebrating 10-Years of SQL Performance Excellence
http://centerfieldtechnology.com/training.asp

-----Original Message-----
Subject: [C400-L] strncpy(profile, buffer, index);

char profile[11];
char buffer[2048];
int index;


strncpy(profile, buffer, index);


does strncpy auto append \0 in profile if index is less than 11 and
buffer is more than 11?


This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.