So, to correct the problem, should I do below or ...:
memset(profile, 0x0, 11)
strncpy(profile, buffer, index);
?
-----Original Message-----
From: c400-l-bounces+lim.hock-chai=usamobility.com@xxxxxxxxxxxx
[mailto:c400-l-bounces+lim.hock-chai=usamobility.com@xxxxxxxxxxxx] On
Behalf Of Sharon Wintermute
Sent: Tuesday, July 24, 2007 1:07 PM
To: 'C programming iSeries / AS400'
Subject: Re: [C400-L] strncpy(profile, buffer, index);
Correct.
-----Original Message-----
From: c400-l-bounces+swintermute=billsoft.com@xxxxxxxxxxxx
[mailto:c400-l-bounces+swintermute=billsoft.com@xxxxxxxxxxxx] On Behalf
Of Lim Hock-Chai
Sent: Tuesday, July 24, 2007 1:05 PM
To: C programming iSeries / AS400
Subject: Re: [C400-L] strncpy(profile, buffer, index);
So if there is no \0 in buffer before it gets to index, no \0 will be
appended to profile?
-----Original Message-----
From: c400-l-bounces+lim.hock-chai=usamobility.com@xxxxxxxxxxxx
[mailto:c400-l-bounces+lim.hock-chai=usamobility.com@xxxxxxxxxxxx] On
Behalf Of Sharon Wintermute
Sent: Tuesday, July 24, 2007 1:03 PM
To: 'C programming iSeries / AS400'
Subject: Re: [C400-L] strncpy(profile, buffer, index);
Strcpy will copy "index" number of characters of "buffer"
to "profile"
strncpy will copy "index" number of characters of "buffer"
to "profile" AND if there is a \0 before you get to "index" it will
stop and place the \0 at the end of profile.
Sharon
-----Original Message-----
From: c400-l-bounces+swintermute=billsoft.com@xxxxxxxxxxxx
[mailto:c400-l-bounces+swintermute=billsoft.com@xxxxxxxxxxxx] On Behalf
Of Elvis Budimlic
Sent: Tuesday, July 24, 2007 12:54 PM
To: 'C programming iSeries / AS400'
Subject: Re: [C400-L] strncpy(profile, buffer, index);
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 is the C programming iSeries / AS400 (C400-L) mailing list To post
a message email: C400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/c400-l.
CONFIDENTIAL
This e-mail and any files transmitted with it are the property of
BillSoft, Incorporated and/or its affiliates, are confidential, and are
intended solely for the use of the individual or entity to whom this
e-mail is addressed. If there is a non-disclosure agreement in effect
between BillSoft and the recipient, the contents of this email and any
files transmitted with it should be treated as confidential under the
terms of such agreement. If you are not one of the named recipients or
otherwise have reason to believe that you have received this e-mail in
error, please notify the sender and delete this message immediately from
your computer. Any other use, retention, dissemination, forwarding,
printing or copying of this e-mail is strictly prohibited.
"BillSoft" and "EZTax" are registered trademarks of BillSoft,
Incorporated.
--
This is the C programming iSeries / AS400 (C400-L) mailing list To post
a message email: C400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/c400-l.
--
This is the C programming iSeries / AS400 (C400-L) mailing list To post
a message email: C400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/c400-l.
CONFIDENTIAL
This e-mail and any files transmitted with it are the property of
BillSoft, Incorporated and/or its affiliates, are confidential, and are
intended solely for the use of the individual or entity to whom this
e-mail is addressed. If there is a non-disclosure agreement in effect
between BillSoft and the recipient, the contents of this email and any
files transmitted with it should be treated as confidential under the
terms of such agreement. If you are not one of the named recipients or
otherwise have reason to believe that you have received this e-mail in
error, please notify the sender and delete this message immediately from
your computer. Any other use, retention, dissemination, forwarding,
printing or copying of this e-mail is strictly prohibited.
"BillSoft" and "EZTax" are registered trademarks of BillSoft,
Incorporated.
--
This is the C programming iSeries / AS400 (C400-L) mailing list To post
a message email: C400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/c400-l.
As an Amazon Associate we earn from qualifying purchases.